結果

問題 No.408 五輪ピック
ユーザー maesoramaesora
提出日時 2017-06-07 14:25:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,028 KB
実行使用メモリ 32,084 KB
最終ジャッジ日時 2023-10-23 18:57:39
合計ジャッジ時間 6,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,216 KB
testcase_01 AC 32 ms
10,216 KB
testcase_02 AC 31 ms
10,216 KB
testcase_03 AC 29 ms
10,216 KB
testcase_04 AC 29 ms
10,216 KB
testcase_05 AC 189 ms
20,828 KB
testcase_06 AC 117 ms
21,144 KB
testcase_07 AC 159 ms
23,080 KB
testcase_08 AC 140 ms
18,552 KB
testcase_09 AC 142 ms
17,920 KB
testcase_10 AC 116 ms
19,088 KB
testcase_11 AC 109 ms
18,388 KB
testcase_12 AC 181 ms
24,036 KB
testcase_13 AC 177 ms
20,828 KB
testcase_14 AC 60 ms
13,696 KB
testcase_15 AC 182 ms
20,192 KB
testcase_16 AC 182 ms
17,668 KB
testcase_17 AC 203 ms
24,256 KB
testcase_18 AC 203 ms
21,708 KB
testcase_19 AC 205 ms
24,772 KB
testcase_20 AC 75 ms
16,092 KB
testcase_21 AC 54 ms
13,564 KB
testcase_22 AC 108 ms
20,460 KB
testcase_23 AC 236 ms
32,084 KB
testcase_24 WA -
testcase_25 AC 178 ms
20,036 KB
testcase_26 AC 213 ms
27,592 KB
testcase_27 AC 185 ms
19,224 KB
testcase_28 AC 132 ms
19,692 KB
testcase_29 AC 132 ms
19,692 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8


def main():
    N, M = map(int, input().split())
    edges = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        edges[a-1].add(b-1)
        edges[b-1].add(a-1)

    # 頂点0から距離2の点,経由点の候補
    d2vs = [set() for _ in range(N)]
    for i in edges[0]:
        for j in edges[i]:
            d2vs[j].add(i)

    # (頂点0から距離2の点)から(頂点0から距離2の点)への辺があり、
    # 別の頂点を経由して行けることを確認
    for i in range(1, N):
        li = len(d2vs[i])
        if li == 0: continue
        for j in edges[i]:
            lj = len(d2vs[j])
            if lj == 0: continue
            if li == 1 and lj == 1:
                if d2vs[i].issubset(d2vs[j]):
                    continue
            return True

    return False


if main():
    print("YES")
else:
    print("NO")

0