結果
問題 | No.92 逃走経路 |
ユーザー | 37zigen |
提出日時 | 2016-03-23 19:45:24 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 240 ms / 5,000 ms |
コード長 | 1,238 bytes |
コンパイル時間 | 2,026 ms |
コンパイル使用メモリ | 78,720 KB |
実行使用メモリ | 58,884 KB |
最終ジャッジ日時 | 2024-04-09 21:10:38 |
合計ジャッジ時間 | 6,953 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 235 ms
58,380 KB |
testcase_01 | AC | 121 ms
53,896 KB |
testcase_02 | AC | 123 ms
54,016 KB |
testcase_03 | AC | 125 ms
54,220 KB |
testcase_04 | AC | 116 ms
53,976 KB |
testcase_05 | AC | 227 ms
58,536 KB |
testcase_06 | AC | 206 ms
57,708 KB |
testcase_07 | AC | 210 ms
58,728 KB |
testcase_08 | AC | 167 ms
56,776 KB |
testcase_09 | AC | 201 ms
57,540 KB |
testcase_10 | AC | 239 ms
58,008 KB |
testcase_11 | AC | 240 ms
58,064 KB |
testcase_12 | AC | 232 ms
58,024 KB |
testcase_13 | AC | 197 ms
57,064 KB |
testcase_14 | AC | 207 ms
57,076 KB |
testcase_15 | AC | 212 ms
56,876 KB |
testcase_16 | AC | 207 ms
56,828 KB |
testcase_17 | AC | 225 ms
58,884 KB |
testcase_18 | AC | 232 ms
57,796 KB |
testcase_19 | AC | 227 ms
57,668 KB |
ソースコード
package yukicoder244; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt();//the number of the cities int m=sc.nextInt();//the number of the roads int k=sc.nextInt();// int[] a=new int[m]; int[] b=new int[m]; int[] c=new int[m]; for(int i=0;i<m;i++){ a[i]=sc.nextInt();//city number b[i]=sc.nextInt();//city number c[i]=sc.nextInt();//toll } int[] d=new int[k+1]; for(int i=1;i<k+1;i++){ d[i]=sc.nextInt();//record } int[][] dp=new int[k+1][n+1]; for(int i=0;i<k+1;i++){ for(int j=0;j<n+1;j++){ dp[i][j]=0; } } for(int i=0;i<m;i++){ if(c[i]==d[1]){ dp[1][a[i]]=dp[1][b[i]]=1; } } for(int i=2;i<=k;i++){ for(int j=0;j<m;j++){ if(c[j]==d[i]){ if(dp[i-1][a[j]]==1)dp[i][b[j]]=1; if(dp[i-1][b[j]]==1)dp[i][a[j]]=1; } } } TreeSet<Integer> ret=new TreeSet<Integer>(); for(int i=1;i<=n;i++){ if(dp[k][i]==1)ret.add(i); } System.out.println(ret.size()); int count=0; for(Integer r:ret){ count++; System.out.print(r); if(count!=ret.size())System.out.print(" "); } System.out.println(); sc.close(); } }