結果

問題 No.408 五輪ピック
ユーザー rpy3cpprpy3cpp
提出日時 2016-08-05 23:03:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,356 KB
最終ジャッジ日時 2024-04-24 16:07:40
合計ジャッジ時間 5,455 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,624 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 200 ms
21,376 KB
testcase_06 AC 124 ms
22,144 KB
testcase_07 AC 166 ms
23,680 KB
testcase_08 AC 148 ms
19,200 KB
testcase_09 AC 150 ms
18,432 KB
testcase_10 AC 127 ms
19,968 KB
testcase_11 AC 120 ms
19,072 KB
testcase_12 AC 200 ms
24,576 KB
testcase_13 AC 211 ms
21,632 KB
testcase_14 AC 68 ms
14,336 KB
testcase_15 AC 212 ms
20,224 KB
testcase_16 AC 201 ms
18,432 KB
testcase_17 AC 209 ms
25,088 KB
testcase_18 AC 211 ms
22,272 KB
testcase_19 AC 218 ms
25,344 KB
testcase_20 AC 77 ms
16,768 KB
testcase_21 AC 56 ms
14,208 KB
testcase_22 AC 113 ms
20,992 KB
testcase_23 AC 244 ms
34,356 KB
testcase_24 WA -
testcase_25 AC 195 ms
20,736 KB
testcase_26 AC 218 ms
28,160 KB
testcase_27 AC 190 ms
19,840 KB
testcase_28 AC 136 ms
19,968 KB
testcase_29 AC 132 ms
20,224 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, M = map(int, input().split())
    Es = [set() for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        Es[a].add(b)
        Es[b].add(a)
    return N, M, Es

def solve(N, M, Es):
    '''
    Es に頂点0を含む長さ5 の単純閉路が存在するか否かを返す。
    '''
    d1 = Es[0]
    d2 = set()
    for d1i in d1:
        d2 |= Es[d1i]
    bss = [d1 & Esb for Esb in Es]
    for c in d2:
        for d in Es[c]:
            if d in d2:
                if is_valid(c, d, bss):
                    return True
    return False

def is_valid(c, d, bss):
    bs = bss[c]
    es = bss[d]
    return bs ^ es

N, M, Es = read_data()
if solve(N, M, Es):
    print("YES")
else:
    print("NO")
0