結果

問題 No.92 逃走経路
ユーザー mkawa2mkawa2
提出日時 2020-01-03 09:51:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 887 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-05-02 07:05:17
合計ジャッジ時間 2,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
11,008 KB
testcase_01 AC 31 ms
10,624 KB
testcase_02 AC 32 ms
10,624 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 144 ms
10,880 KB
testcase_06 AC 34 ms
11,136 KB
testcase_07 AC 33 ms
11,136 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 38 ms
10,752 KB
testcase_10 AC 144 ms
10,880 KB
testcase_11 AC 135 ms
10,880 KB
testcase_12 AC 146 ms
10,880 KB
testcase_13 AC 37 ms
10,880 KB
testcase_14 AC 40 ms
10,880 KB
testcase_15 AC 43 ms
10,880 KB
testcase_16 AC 41 ms
10,752 KB
testcase_17 AC 43 ms
11,008 KB
testcase_18 AC 37 ms
11,008 KB
testcase_19 AC 36 ms
11,008 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