結果

問題 No.679 不思議マーケット
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-30 12:48:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 76,728 KB
最終ジャッジ日時 2023-09-10 09:31:30
合計ジャッジ時間 3,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,252 KB
testcase_01 AC 72 ms
71,188 KB
testcase_02 AC 72 ms
71,248 KB
testcase_03 AC 92 ms
76,728 KB
testcase_04 AC 81 ms
76,288 KB
testcase_05 AC 82 ms
76,336 KB
testcase_06 AC 80 ms
76,424 KB
testcase_07 AC 74 ms
71,196 KB
testcase_08 AC 85 ms
76,392 KB
testcase_09 AC 74 ms
71,236 KB
testcase_10 AC 80 ms
76,152 KB
testcase_11 AC 74 ms
71,352 KB
testcase_12 AC 81 ms
76,516 KB
testcase_13 AC 85 ms
76,580 KB
testcase_14 AC 82 ms
76,184 KB
testcase_15 AC 74 ms
71,512 KB
testcase_16 AC 71 ms
71,336 KB
testcase_17 AC 74 ms
71,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
deg = [0] * N
for _ in range(M):
    x, p = map(int, input().split())
    x -= 1
    deg[x] += p
    for y in map(int, input().split()):
        G[y - 1].append(x)

ans = 0
que = [i for i, d in enumerate(deg) if d == 0]
while que:
    s = que.pop()
    ans += 1
    for t in G[s]:
        deg[t] -= 1
        if deg[t] == 0:
            que.append(t)
print(ans)
0