Untitled
unknown
plain_text
2 years ago
1.7 kB
8
Indexable
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Solution {
static int n, m, k, j;
static double[][] a = new double[305][305];
static int[] vs = new int[305];
static int res1, res2;
public static void main(String[] args) throws FileNotFoundException {
//Scanner sc = new Scanner(System.in);
Scanner sc = new Scanner(new File("C:\\Users\\SVMC\\workspace\\adv\\Test\\src\\input.txt"));
int T = 1;
for(int t=1; t<=T; t++){
n = sc.nextInt();
m = sc.nextInt();
k = sc.nextInt();
j = sc.nextInt();
k = j-k;
if(k%10==0){
k/=10;
}else{
k =k/10+1;
}
if(j%10==0){
j/=10;
}else{
j =j/10+1;
}
for(int i=0; i<m; i++){
int xx = sc.nextInt();
int yy = sc.nextInt();
double dept = sc.nextDouble();
a[xx][yy] = dept;
}
System.out.println(k+" "+j);
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
BFS();
System.out.println(res2);
}
}
static void BFS(){
int[] q = new int[205];
int l=0, r=0;
q[r++]=1;
vs[1]=1;
int cnt=0;
while(l<r && cnt<j){
int top = q[l++];
cnt++;
System.out.println(cnt);
int max = 0, idx=-1;
for(int i=1; i<=n; i++){
if(a[top][i]>0){
vs[i]+=vs[top]*a[top][i];
if(vs[i]>max){
max=vs[i]; idx=i;
}
q[r++]=i;
}
}
printVS();
}
}
static void printVS(){
System.out.println();
for(int i=1; i<=n; i++){
System.out.print(vs[i]+" ");
}
System.out.println();
}
}
Editor is loading...