結果

問題 No.92 逃走経路
ユーザー mkawa2mkawa2
提出日時 2019-12-24 00:48:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 170 ms / 5,000 ms
コード長 887 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 10,376 KB
最終ジャッジ日時 2023-10-19 09:13:56
合計ジャッジ時間 2,353 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
10,368 KB
testcase_01 AC 30 ms
10,020 KB
testcase_02 AC 32 ms
10,020 KB
testcase_03 AC 32 ms
10,020 KB
testcase_04 AC 30 ms
10,020 KB
testcase_05 AC 170 ms
10,132 KB
testcase_06 AC 32 ms
10,376 KB
testcase_07 AC 32 ms
10,368 KB
testcase_08 AC 30 ms
10,040 KB
testcase_09 AC 37 ms
10,056 KB
testcase_10 AC 165 ms
10,124 KB
testcase_11 AC 144 ms
10,112 KB
testcase_12 AC 154 ms
10,140 KB
testcase_13 AC 34 ms
10,132 KB
testcase_14 AC 42 ms
10,128 KB
testcase_15 AC 41 ms
10,176 KB
testcase_16 AC 39 ms
10,176 KB
testcase_17 AC 41 ms
10,212 KB
testcase_18 AC 36 ms
10,212 KB
testcase_19 AC 34 ms
10,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,m,k=MI()
    ctoe=defaultdict(list)
    for _ in range(m):
        a,b,c=MI()
        ctoe[c].append([a,b])
    cc=LI()
    now=set()
    for a,b in ctoe[cc[0]]:
        now.add(a)
        now.add(b)
    for c in cc[1:]:
        nxt=set()
        for a,b in ctoe[c]:
            if a in now:nxt.add(b)
            if b in now:nxt.add(a)
        now=nxt
    print(len(now))
    now=list(now)
    now.sort()
    print(*now)


main()
0