# Untitled

unknown
plain_text
19 days ago
1.9 kB
0
Indexable
Never
```#1 1 1.000000 1 1.000000
#2 11 1.000000 18 1.000000
#3 4 0.386860 4 0.386860
#4 10 0.946340 10 0.851171
#5 3 0.150855 1 1.000000
#6 15 0.284926 7 0.505935
#7 4 0.118507 4 0.118507
#8 5 0.121474 5 0.121474
#9 3 0.591954 3 0.637576
#10 7 0.314579 6 0.280350

public class Solution {
static int N, E, K , T;
static int len = 201;
static double[][] arr = new double[len][len];
static double[][] timeXacSuat = new double[len][len];

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (int tcid = 1; tcid <= 15; tcid++) {
N = sc.nextInt();	//so phong ban
E = sc.nextInt();	//so mui ten
K = sc.nextInt();	//time kang
T = sc.nextInt();	//time = minutes
reset();
for (int i = 0; i < E; i++) {
int dinh1 = sc.nextInt();
int dinh2 = sc.nextInt();
arr[dinh1][dinh2] = sc.nextDouble();

}

//node
timeXacSuat[1][0] = 1;
for(int t = 1; t <= T/10; t++){
for(int i = 1; i <= N; i++){
if(timeXacSuat[i][t-1] != 0){
for(int j = 1; j <= N; j++){
if(arr[i][j] != 0){
timeXacSuat[j][t] += timeXacSuat[i][t-1]*arr[i][j];
}
}
}
}
}
//Jang start tai 0, Kang tai K
//10p di chuyen 1 lan
int jangTime = T/10, kangTime = (T-K)/10;
int jangD = 0, kangD = 0;
double jangXS = 0, kangXS = 0;
for(int i = 1; i <= N; i++){
if(timeXacSuat[i][jangTime] > jangXS){
jangXS = (double) timeXacSuat[i][jangTime];
jangD = i;
}
if(timeXacSuat[i][kangTime] > kangXS){
kangXS = (double) timeXacSuat[i][kangTime];
kangD = i;
}
}

System.out.print("#" + tcid + " ");
System.out.printf("%d %.6f %d %.6f\n", jangD, jangXS, kangD, kangXS);
}
sc.close();
}

private static void reset(){
for(int i = 0; i < arr.length; i++){
for(int j = 0; j < arr[i].length; j++){
arr[i][j] = 0;
timeXacSuat[i][j] = 0;
}
}
}
}```