Submission #00058


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.*;
public class Main{
public static void main(String[] $){
var s=new Scanner(System.in);
int n=s.nextInt(), m=s.nextInt(), k=s.nextInt();
ArrayList<ArrayList<Integer>> out=new ArrayList<>();
for(int i=0;i<n;++i){
out.add(new ArrayList<>(3));
}
for(int i=0;i<m;++i){
int f=s.nextInt()-1, t=s.nextInt()-1, c=s.nextInt();
out.get(f).add(t*1001+c);
}
int[] parent=new int[n], d=new int[n];
Arrays.fill(d,Integer.MAX_VALUE);
Arrays.fill(parent,-2);
for(int i=0;i<k;++i){
int v=s.nextInt();
parent[v-1]=v;
d[v-1]=0;
}
for(int i=0;i<n;++i)
f(i,out,parent,d);
Arrays.stream(parent).forEach(System.out::println);
}
private static void f(int i,ArrayList<ArrayList<Integer>> out,int[] parent,int[] d){
if(parent[i] >= -1)
return;
parent[i]=-1;
for(Integer o: out.get(i)){
int t=o/1001;
f(t,out,parent,d);
int np=parent[t];
int nd=d[t]+o%1001;
if(np>0){
if(parent[i]==-1||(d[i]>nd||(d[i]==nd&&np<parent[i]))){
d[i]=nd;
parent[i]=np;
}
}
}
}
}

ステータス

項目 データ
問題 0003 - 避難 (Evacuation)
ユーザー名 fal_rnd
投稿日時 2019-02-28 15:59:32
言語 Java
状態 Wrong Answer
得点 0
ソースコード長 1091 Byte
最大実行時間 1000 ms
最大メモリ使用量 33524 KB

セット

セット 得点 Cases
1 SubTask-A 0 / 1.2 input-A*
2 SubTask-B 0 / 4.8 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-A01 WA 167 ms 19032 KB
1
2
input-A02 WA 147 ms 19460 KB
1
2
input-A03 WA 138 ms 19512 KB
1
2
input-A04 AC 133 ms 15892 KB
1
2
input-A05 AC 129 ms 15788 KB
1
2
input-A06 WA 147 ms 21164 KB
1
2
input-A07 WA 137 ms 19220 KB
1
2
input-A08 WA 163 ms 19936 KB
1
2
input-A09 WA 162 ms 18912 KB
1
2
input-A10 WA 166 ms 21920 KB
1
2
input-A11 WA 175 ms 19668 KB
1
2
input-A12 AC 125 ms 15784 KB
1
2
input-A13 AC 125 ms 15916 KB
1
2
input-B01 WA 166 ms 19068 KB
2
input-B02 AC 142 ms 19588 KB
2
input-B03 WA 256 ms 19884 KB
2
input-B04 WA 253 ms 20056 KB
2
input-B05 WA 495 ms 22040 KB
2
input-B06 WA 469 ms 22092 KB
2
input-B07 RE 563 ms 23016 KB
2
input-B08 WA 730 ms 23568 KB
2
input-B09 RE 634 ms 23524 KB
2
input-B10 RE 585 ms 23520 KB
2
input-B11 TLE 1000 ms 27668 KB
2
input-B12 TLE 1000 ms 27740 KB
2
input-B13 AC 693 ms 28812 KB
2
input-B14 TLE 1000 ms 31608 KB
2
input-B15 TLE 1000 ms 31632 KB
2
input-B16 TLE 1000 ms 33524 KB
2
input-B17 RE 581 ms 30172 KB
2
input-B18 AC 152 ms 20536 KB
2
input-sample01 AC 127 ms 16432 KB
2
input-sample02 AC 121 ms 16564 KB
2
input-sample03 AC 133 ms 16444 KB
2