結果

問題 No.679 不思議マーケット
ユーザー convexineqconvexineq
提出日時 2021-03-13 17:31:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 69,888 KB
最終ジャッジ日時 2024-04-23 08:18:39
合計ジャッジ時間 1,768 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,224 KB
testcase_01 AC 36 ms
52,352 KB
testcase_02 AC 36 ms
51,968 KB
testcase_03 AC 61 ms
69,376 KB
testcase_04 AC 53 ms
68,480 KB
testcase_05 AC 53 ms
67,584 KB
testcase_06 AC 63 ms
69,888 KB
testcase_07 AC 46 ms
55,424 KB
testcase_08 AC 55 ms
68,480 KB
testcase_09 AC 33 ms
51,968 KB
testcase_10 AC 46 ms
61,696 KB
testcase_11 AC 49 ms
55,680 KB
testcase_12 AC 58 ms
69,760 KB
testcase_13 AC 58 ms
68,864 KB
testcase_14 AC 49 ms
63,872 KB
testcase_15 AC 44 ms
61,952 KB
testcase_16 AC 33 ms
52,224 KB
testcase_17 AC 32 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
g = [[] for _ in range(n)]
indegree = [0]*n
for _ in range(m):
    x,_ = map(int,input().split())
    x -= 1
    for r in map(int,input().split()):
        g[r-1].append(x)
        indegree[x] += 1

ans = 0
q = [i for i in range(n) if indegree[i]==0]
while q:
    v = q.pop()
    ans += 1
    for c in g[v]:
        indegree[c] -= 1
        if indegree[c] == 0:
            q.append(c)
print(ans)
0