結果

問題 No.1023 Cyclic Tour
ユーザー chineristAC
提出日時 2020-10-08 16:39:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 423 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 96,256 KB
最終ジャッジ日時 2024-07-20 05:57:49
合計ジャッジ時間 19,159 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 18 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
edge = [[] for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    edge[a-1].append(b-1)
    if c==1:
        edge[b-1].append(a-1)

used = [False]*N
used[0] = True
def dfs(v,pv):
    for nv in edge[v]:
        if used[nv]:
            if nv!=pv:
                exit(print("Yes"))
        else:
            used[nv] = True
            dfs(nv,v)

dfs(0,-1)
print("No")
0