結果

問題 No.408 五輪ピック
ユーザー rpy3cpprpy3cpp
提出日時 2016-08-06 01:00:28
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 29,380 KB
最終ジャッジ日時 2023-08-06 21:35:25
合計ジャッジ時間 5,990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,904 KB
testcase_01 AC 16 ms
7,924 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,944 KB
testcase_04 AC 16 ms
7,788 KB
testcase_05 AC 196 ms
18,600 KB
testcase_06 AC 127 ms
19,280 KB
testcase_07 AC 176 ms
20,908 KB
testcase_08 AC 144 ms
16,836 KB
testcase_09 AC 146 ms
15,832 KB
testcase_10 AC 121 ms
17,384 KB
testcase_11 AC 114 ms
16,584 KB
testcase_12 AC 200 ms
21,908 KB
testcase_13 AC 193 ms
18,788 KB
testcase_14 AC 52 ms
11,500 KB
testcase_15 AC 198 ms
17,756 KB
testcase_16 AC 195 ms
15,968 KB
testcase_17 AC 212 ms
22,444 KB
testcase_18 AC 215 ms
19,708 KB
testcase_19 AC 229 ms
22,900 KB
testcase_20 AC 73 ms
14,056 KB
testcase_21 AC 46 ms
11,548 KB
testcase_22 AC 115 ms
18,268 KB
testcase_23 AC 271 ms
29,380 KB
testcase_24 AC 197 ms
22,676 KB
testcase_25 AC 186 ms
18,220 KB
testcase_26 AC 242 ms
25,568 KB
testcase_27 AC 190 ms
17,360 KB
testcase_28 AC 133 ms
17,520 KB
testcase_29 AC 134 ms
17,468 KB
testcase_30 AC 15 ms
7,844 KB
testcase_31 AC 15 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_valid(c, d, bs):
    b = bs[c] - {d}
    e = bs[d] - {c}
    return b and e and len(b | e) >= 2
N, M = map(int, input().split())
Es = [set() for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    Es[a-1].add(b-1)
    Es[b-1].add(a-1)
d1 = Es[0]
d2 = set()
for d in d1: d2 |= Es[d]
d2 -= {0}
bs = [d1 & Eb for Eb in Es]
for c in d2:
    for d in Es[c]:
        if d in d2 and is_valid(c, d, bs):
            print("YES")
            break
    else:continue
    break
else:print("NO")
0