結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-24 03:19:29 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,299 bytes |
| コンパイル時間 | 3,626 ms |
| コンパイル使用メモリ | 77,776 KB |
| 実行使用メモリ | 58,040 KB |
| 最終ジャッジ日時 | 2024-07-07 17:19:06 |
| 合計ジャッジ時間 | 8,327 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 RE * 13 |
ソースコード
import java.util.Scanner;
public class Yuki92{
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int n,k,m,res = 0,count = 0;
boolean flag=false;
n = sc.nextInt();
m = sc.nextInt();
k = sc.nextInt();
int[] a = new int[k];
int[] b = new int[k];
int[] c = new int[k];
int[] d = new int[m];
for(int i = 0;i<k;i++){
a[i] = sc.nextInt();
b[i] = sc.nextInt();
c[i] = sc.nextInt();
}
for(int i = 0; i<m;i++){
d[i] = sc.nextInt();
}
int[] prev = new int[n];
int[] next = new int[n];
for(int i = 0;i<m;i++){
if(c[i] == d[0]){
prev[a[i]-1] = 1;
prev[b[i]-1] = 1;
}
}
for(int i = 1;i<k;i++){
for(int j = 0;j<n;j++){
if(prev[j] == 1){
for(int l = 0;l<m;l++){
if(d[i] == c[l]){
if(a[l] == j + 1)next[b[l]-1]=1;
if(b[l] == j + 1)next[a[l]-1]=1;
}
}
}
}
for(int j = 0;j<n;j++){
prev[j] = next[j];
next[j] = 0;
}
}
for(int i = 0;i<n;i++){
if(prev[i] == 1)res++;
}
System.out.println(res);
for(int i = 0;i<n;i++){
if(count < res - 1&& prev[i] == 1){
System.out.print(i+1);
System.out.print(" ");
flag = true;
}
if(count == res-1 && prev[i] == 1)System.out.println(i+1);
if(flag){
count++;
flag = false;
}
}
}
}