結果

問題 No.92 逃走経路
ユーザー ktshunktshun
提出日時 2015-06-19 11:05:37
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 6,644 KB
最終ジャッジ日時 2023-09-21 09:44:10
合計ジャッジ時間 6,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 14 ms
6,352 KB
testcase_02 AC 13 ms
6,228 KB
testcase_03 AC 13 ms
6,464 KB
testcase_04 AC 13 ms
6,348 KB
testcase_05 AC 18 ms
6,324 KB
testcase_06 AC 18 ms
6,548 KB
testcase_07 AC 18 ms
6,604 KB
testcase_08 AC 15 ms
6,436 KB
testcase_09 AC 115 ms
6,292 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-
from collections import defaultdict

if __name__ == "__main__":
	n,m,k = map(int,raw_input().split())
	roads = defaultdict(set)
	for i in xrange(m):
		a,b,c = map(int,raw_input().split())
		roads[c].add((a,b))
	D = map(int,raw_input().split())
	now = []
	prev = []
	for i in roads[D[0]]:
		now.append(i[0])
		now.append(i[1])
	for d in D[1::]:
		prev = now
		now = []
		for i in roads[d]:
			if i[0] in prev:
				now.append(i[1])
			if i[1] in prev:
				now.append(i[0])
	now.sort()
	now = map(str,now)
	print len(now)
	print ' '.join(now)
0