結果

問題 No.679 不思議マーケット
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-13 12:31:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 566 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 10,632 KB
最終ジャッジ日時 2023-10-24 16:38:28
合計ジャッジ時間 1,711 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,168 KB
testcase_01 AC 27 ms
10,168 KB
testcase_02 AC 26 ms
10,168 KB
testcase_03 AC 33 ms
10,508 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 29 ms
10,224 KB
testcase_08 RE -
testcase_09 AC 27 ms
10,168 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 30 ms
10,264 KB
testcase_16 RE -
testcase_17 AC 26 ms
10,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
goods = [[]for i in range(n+1)]

def search(i,x):
    if goods[i]==-1:
        return False
    else:
        for j in goods[i]:
            if j==x:return
            if search(j,x):goods[j]=[]
            else:
                goods[j]=-1
                return False
        return True

for i in range(m):
    g,r = map(int,input().split())
    h = list(map(int,input().split()))
    goods[g] = h

cnt = 0
for i in range(1,n+1):
    if search(i,i):
        goods[i] = []
    else:
        goods[i] = -1
        cnt+=1

print(n-cnt)
0