結果

問題 No.679 不思議マーケット
ユーザー rlangevinrlangevin
提出日時 2023-06-08 00:03:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 77,756 KB
最終ジャッジ日時 2023-08-28 19:33:05
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,208 KB
testcase_01 AC 72 ms
71,460 KB
testcase_02 AC 73 ms
71,476 KB
testcase_03 AC 112 ms
77,756 KB
testcase_04 AC 98 ms
77,140 KB
testcase_05 AC 94 ms
77,128 KB
testcase_06 AC 101 ms
77,424 KB
testcase_07 AC 81 ms
71,100 KB
testcase_08 AC 98 ms
77,732 KB
testcase_09 AC 74 ms
71,108 KB
testcase_10 AC 90 ms
76,468 KB
testcase_11 AC 82 ms
71,512 KB
testcase_12 AC 88 ms
76,800 KB
testcase_13 AC 92 ms
76,416 KB
testcase_14 AC 87 ms
76,460 KB
testcase_15 AC 85 ms
75,652 KB
testcase_16 AC 73 ms
71,516 KB
testcase_17 AC 72 ms
71,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
G = [[] for i in range(N)]
deg = [0] * N
for i in range(M):
    g, r = map(int, input().split())
    g -= 1
    H = list(map(int, input().split()))
    for h in H:
        G[h - 1].append(g)
        deg[g] += 1
        
stack = []
for i in range(N):
    if deg[i] == 0:
        stack.append(i)
        
while stack:
    p = stack.pop()
    for u in G[p]:
        deg[u] -= 1
        if deg[u] == 0:
            stack.append(u)

print(deg.count(0))
0