結果

問題 No.2664 Prime Sum
ユーザー ntudantuda
提出日時 2024-03-09 00:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,904 KB
最終ジャッジ日時 2024-03-09 00:15:43
合計ジャッジ時間 4,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,332 KB
testcase_01 AC 34 ms
53,332 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 37 ms
53,332 KB
testcase_04 AC 35 ms
53,332 KB
testcase_05 AC 56 ms
63,748 KB
testcase_06 AC 49 ms
63,784 KB
testcase_07 AC 40 ms
53,332 KB
testcase_08 AC 46 ms
60,884 KB
testcase_09 AC 52 ms
63,748 KB
testcase_10 AC 47 ms
61,524 KB
testcase_11 AC 36 ms
53,332 KB
testcase_12 AC 58 ms
55,468 KB
testcase_13 AC 51 ms
63,748 KB
testcase_14 AC 95 ms
70,836 KB
testcase_15 AC 103 ms
70,808 KB
testcase_16 AC 112 ms
70,828 KB
testcase_17 AC 58 ms
55,468 KB
testcase_18 AC 73 ms
63,748 KB
testcase_19 AC 107 ms
63,748 KB
testcase_20 AC 90 ms
70,836 KB
testcase_21 AC 94 ms
70,796 KB
testcase_22 AC 65 ms
63,756 KB
testcase_23 AC 87 ms
72,904 KB
testcase_24 AC 89 ms
72,860 KB
testcase_25 AC 84 ms
70,792 KB
testcase_26 AC 54 ms
53,332 KB
testcase_27 AC 55 ms
53,332 KB
testcase_28 AC 56 ms
53,332 KB
testcase_29 AC 53 ms
53,332 KB
testcase_30 AC 51 ms
53,332 KB
testcase_31 AC 55 ms
53,332 KB
testcase_32 AC 79 ms
53,332 KB
testcase_33 AC 64 ms
53,332 KB
testcase_34 AC 58 ms
53,332 KB
testcase_35 AC 65 ms
55,468 KB
testcase_36 AC 71 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
E = [[] for _ in range(N)]
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)
C = [-1] * N
def bfs(x):
    for y in E[x]:
        if C[y] == C[x]:
            print("No")
            exit()
        if C[y] == -1:
            C[y] = C[x] ^ 1
            bfs(y)

for i in range(N):
    if C[i] == -1:
        C[i] = 0
        bfs(i)

print("Yes")

0