結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
amyu
|
| 提出日時 | 2016-06-17 20:24:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,765 bytes |
| コンパイル時間 | 2,720 ms |
| コンパイル使用メモリ | 82,516 KB |
| 実行使用メモリ | 75,940 KB |
| 最終ジャッジ日時 | 2024-10-09 16:57:48 |
| 合計ジャッジ時間 | 15,016 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
import java.util.*;
import java.io.*;
public class Main{
static final Scanner sc = new Scanner(System.in);
static final PrintWriter out = new PrintWriter(System.out,false);
public static void main(String[] args){
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int[] a = new int[m];
int[] b = new int[m];
long[] c = new long[m];
for(int i=0;i<m;i++){
a[i] = sc.nextInt()-1;
b[i] = sc.nextInt()-1;
c[i] = sc.nextLong();
}
long[] d = new long[k];
for(int i=0;i<k;i++){
d[i] = sc.nextLong();
}
ArrayList<Integer> list1 = new ArrayList<Integer>();
ArrayList<Integer> list2 = new ArrayList<Integer>();
for(int i=0;i<n;i++){
list1.add(i);
}
int count = 0;
while(count<k){
for(int i=0;i<list1.size();i++){
int x = list1.get(i);
for(int j=0;j<m;j++){
if(a[j]==x && d[count]==c[j]){
list2.add(b[j]);
}
else if(b[j]==x && d[count]==c[j]){
list2.add(a[j]);
}
}
}
list1.clear();
for(int i=0;i<list2.size();i++){
list1.add(list2.get(i));
}
list2.clear();
count++;
}
out.println(list1.size());
for(Iterator<Integer> iterator = list1.iterator();iterator.hasNext();){
out.print((iterator.next()+1)+" ");
}
out.println();
out.flush();
}
//static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
amyu