結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー ThetaTheta
提出日時 2024-03-08 11:55:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-03-08 11:55:08
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    graph = [set() for _ in range(N)]
    degrees = [0] * N
    for _ in range(M):
        A, B = map(lambda n: int(n) - 1, input().split())
        graph[A].add(B)
        graph[B].add(A)

    removable_edges = set()
    for idx, neighbors in enumerate(graph):
        if len(neighbors) != 1:
            continue
        for neighbor in neighbors:
            removable_edges.add((min(idx, neighbor), max(idx, neighbor)))

    ctr = 0
    while removable_edges:
        cur_edge = removable_edges.pop()
        graph[cur_edge[0]].remove(cur_edge[1])
        graph[cur_edge[1]].remove(cur_edge[0])
        ctr += 1
        if len(graph[cur_edge[0]]) == 1:
            for neighbor in graph[cur_edge[0]]:
                removable_edges.add(
                    (min(
                        cur_edge[0], neighbor), max(
                        cur_edge[0], neighbor)))
        if len(graph[cur_edge[1]]) == 1:
            for neighbor in graph[cur_edge[1]]:
                removable_edges.add(
                    (min(
                        cur_edge[1], neighbor), max(
                        cur_edge[1], neighbor)))
    if ctr % 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
0