結果

問題 No.92 逃走経路
ユーザー fal_rndfal_rnd
提出日時 2017-01-20 17:52:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 321 ms / 5,000 ms
コード長 1,135 bytes
コンパイル時間 3,800 ms
コンパイル使用メモリ 78,960 KB
実行使用メモリ 61,672 KB
最終ジャッジ日時 2023-08-24 18:19:33
合計ジャッジ時間 9,934 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
61,672 KB
testcase_01 AC 127 ms
55,676 KB
testcase_02 AC 130 ms
55,780 KB
testcase_03 AC 126 ms
55,756 KB
testcase_04 AC 127 ms
55,604 KB
testcase_05 AC 293 ms
60,292 KB
testcase_06 AC 257 ms
59,980 KB
testcase_07 AC 252 ms
60,300 KB
testcase_08 AC 190 ms
56,228 KB
testcase_09 AC 211 ms
57,308 KB
testcase_10 AC 315 ms
60,096 KB
testcase_11 AC 318 ms
60,192 KB
testcase_12 AC 321 ms
60,344 KB
testcase_13 AC 211 ms
57,068 KB
testcase_14 AC 217 ms
59,088 KB
testcase_15 AC 225 ms
59,084 KB
testcase_16 AC 234 ms
59,232 KB
testcase_17 AC 268 ms
60,244 KB
testcase_18 AC 263 ms
60,304 KB
testcase_19 AC 259 ms
59,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package src;

import java.util.*;
public class A{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int n=s.nextInt()+1,m=s.nextInt(),k=s.nextInt();
		BitSet[] dp = new BitSet[k+1];
						{
							for(int i=0;i<dp.length;i++) dp[i] = new BitSet(n);
							dp[0].set(1,n);
						}
		Way[] way =new Way[m*2];
						{
							int a,b,c;
							for(int i=0;i<m;i++) {
								a=s.nextInt();
								b=s.nextInt();
								c=s.nextInt();
								way[i*2  ]=new Way(a, b, c);
								way[i*2+1]=new Way(b, a, c);
							}
						}
		int[] pay = new int[k];
						{
							for(int i=0;i<k;i++) pay[i]=s.nextInt();
							Arrays.sort(way, (o1,o2)->o1.c-o2.c);
						}
		for(int i=0;i<k;i++) {
			int p=pay[i];
			for(Way w:way) {
				if(w.c==p && dp[i].get(w.a)) {
					dp[i+1].set(w.b);
				}
			}
		}
		System.out.println(dp[k].cardinality());
		System.out.println(dp[k].toString().replaceAll("[^0-9,]", "").replaceAll(",", " "));
		/*
		System.out.println();
		for(int i=0;i<k;i++) System.out.println(dp[i].toString());
		*/
	}
}
class Way{
	int a,b,c;
	Way(int p,int q,int r) {
		a=p;
		b=q;
		c=r;
	}
}
0