結果
問題 | No.679 不思議マーケット |
ユーザー |
![]() |
提出日時 | 2018-07-16 14:33:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-17 09:08:30 |
合計ジャッジ時間 | 1,605 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
n,m = map(int,input().split()) goods_dic = {} count = n c = 0 def search(goods): if goods_dic[goods]==False: return False elif goods_dic[goods]==[]: return True else: tmp = goods_dic[goods][:] goods_dic[goods] = False for i in tmp: if not search(i): global count count -= 1 return False else: goods_dic[goods]=[] return True for i in range(1,n+1): goods_dic[i] = [] for i in range(m): tmp1 = list(map(int,input().split())) tmp2 = list(map(int,input().split())) goods_dic[tmp1[0]] = tmp2 for i in range(1,n+1): search(i) print(count)