結果

問題 No.2664 Prime Sum
ユーザー OhnoHirokiOhnoHiroki
提出日時 2024-03-21 00:26:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-03-21 00:26:08
合計ジャッジ時間 4,536 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,112 KB
testcase_01 WA -
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 31 ms
10,112 KB
testcase_04 AC 30 ms
10,112 KB
testcase_05 AC 32 ms
10,112 KB
testcase_06 AC 32 ms
10,112 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 31 ms
10,112 KB
testcase_13 AC 32 ms
10,112 KB
testcase_14 AC 33 ms
10,112 KB
testcase_15 AC 32 ms
10,112 KB
testcase_16 AC 33 ms
10,112 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 32 ms
10,112 KB
testcase_23 AC 35 ms
10,112 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 29 ms
10,112 KB
testcase_27 AC 29 ms
10,112 KB
testcase_28 AC 29 ms
10,112 KB
testcase_29 AC 30 ms
10,112 KB
testcase_30 AC 30 ms
10,112 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 29 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int, input().split())

path = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int, input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)

ans = "Yes"
memo = [-1 for _ in range(n)]
for i in range(n):
    if memo != -1:
        continue
    d = [i]
    memo[i] = 0
    while d:
        j = d.pop()
        for k in path[j]:
            if memo[k] == -1:
                memo[k] = memo[j] ^ 1
                d.append(k)
            elif memo[k] == memo[j]:
                ans = "No"
print(ans)
0