結果

問題 No.679 不思議マーケット
ユーザー convexineq
提出日時 2021-03-13 17:31:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 69,504 KB
最終ジャッジ日時 2024-10-15 08:09:15
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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