結果
問題 |
No.2418 情報通だよ!Nafmoくん
|
ユーザー |
![]() |
提出日時 | 2023-08-12 14:35:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 566 bytes |
コンパイル時間 | 446 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 108,544 KB |
最終ジャッジ日時 | 2024-11-19 20:15:52 |
合計ジャッジ時間 | 6,101 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 WA * 20 |
ソースコード
import sys sys.setrecursionlimit(2*10**5) N,M=map(int,input().split()) edge=[[] for _ in range(2*N)] for i in range(M): a,b=map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) use=[False for _ in range(2*N)] ans=0 def dfs(i): global use,ans use[i]=True con=False for e in edge[i]: if not use[e]: r=dfs(e) if r==True: con=True if con: ans+=1 return False else: return True for i in range(2*N): if not use[i]: dfs(i) print(N-ans)