結果

問題 No.2664 Prime Sum
ユーザー suisensuisen
提出日時 2023-11-19 18:18:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 78,240 KB
最終ジャッジ日時 2024-01-05 15:01:17
合計ジャッジ時間 4,694 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
68,232 KB
testcase_01 AC 59 ms
68,232 KB
testcase_02 AC 67 ms
68,232 KB
testcase_03 AC 61 ms
68,232 KB
testcase_04 AC 60 ms
68,232 KB
testcase_05 AC 72 ms
72,736 KB
testcase_06 AC 70 ms
70,548 KB
testcase_07 AC 65 ms
68,232 KB
testcase_08 AC 68 ms
70,292 KB
testcase_09 AC 73 ms
72,352 KB
testcase_10 AC 69 ms
70,292 KB
testcase_11 AC 62 ms
68,232 KB
testcase_12 AC 67 ms
70,292 KB
testcase_13 AC 73 ms
72,736 KB
testcase_14 AC 92 ms
78,240 KB
testcase_15 AC 92 ms
78,240 KB
testcase_16 AC 93 ms
78,240 KB
testcase_17 AC 70 ms
68,232 KB
testcase_18 AC 73 ms
72,736 KB
testcase_19 AC 75 ms
72,736 KB
testcase_20 AC 93 ms
78,240 KB
testcase_21 AC 90 ms
78,112 KB
testcase_22 AC 73 ms
72,748 KB
testcase_23 AC 93 ms
78,240 KB
testcase_24 AC 91 ms
78,112 KB
testcase_25 AC 89 ms
78,112 KB
testcase_26 AC 61 ms
68,232 KB
testcase_27 AC 64 ms
68,232 KB
testcase_28 AC 64 ms
68,232 KB
testcase_29 AC 65 ms
68,232 KB
testcase_30 AC 61 ms
68,232 KB
testcase_31 AC 61 ms
68,232 KB
testcase_32 AC 63 ms
68,232 KB
testcase_33 AC 62 ms
68,232 KB
testcase_34 AC 62 ms
68,232 KB
testcase_35 AC 64 ms
68,232 KB
testcase_36 AC 59 ms
68,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List


def is_bipartite(G: List[List[int]]):
    n = len(G)
    C = [-1] * n
    for s in range(n):
        if C[s] != -1:
            continue

        C[s] = 0

        Q = [s]
        for u in Q:
            for v in G[u]:
                if C[v] == -1:
                    C[v] = C[u] ^ 1
                    Q.append(v)
                elif C[v] == C[u]:
                    return False
        
    return True


n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)

if is_bipartite(G):
    print("Yes")
else:
    print("No")
0