結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー nikoro256
提出日時 2023-08-12 14:34:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 94,548 KB
最終ジャッジ日時 2024-11-19 20:04:38
合計ジャッジ時間 6,998 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 13 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    print(i,con)
    if con:
        ans+=1
        return False
    else:
        return True

for i in range(2*N):
    if not use[i]:
        dfs(i)
print(N-ans)
0