結果

問題 No.408 五輪ピック
ユーザー convexineqconvexineq
提出日時 2021-02-10 00:44:44
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 693 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 90,260 KB
最終ジャッジ日時 2023-09-21 12:10:34
合計ジャッジ時間 7,276 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,316 KB
testcase_01 AC 74 ms
71,480 KB
testcase_02 AC 75 ms
71,432 KB
testcase_03 AC 76 ms
71,280 KB
testcase_04 AC 76 ms
71,320 KB
testcase_05 AC 161 ms
79,132 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 AC 145 ms
79,984 KB
testcase_09 MLE -
testcase_10 AC 144 ms
79,468 KB
testcase_11 AC 135 ms
78,976 KB
testcase_12 MLE -
testcase_13 AC 141 ms
79,592 KB
testcase_14 AC 123 ms
78,644 KB
testcase_15 AC 140 ms
78,976 KB
testcase_16 AC 152 ms
79,392 KB
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 124 ms
79,488 KB
testcase_21 AC 119 ms
78,604 KB
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 AC 138 ms
79,312 KB
testcase_26 MLE -
testcase_27 AC 141 ms
79,452 KB
testcase_28 MLE -
testcase_29 MLE -
testcase_30 AC 75 ms
71,464 KB
testcase_31 AC 77 ms
71,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
g = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)
    
size = [0]*n
res = [None]*n
for i in range(1,n):
    s = g[0]&g[i]
    if len(s) >= 3:
        size[i] = 3
    else:
        size[i] = len(s)
        res[i] = s

for a in range(1,n):
    if size[a] == 0: continue
    for b in g[a]:
        if b==0 or size[b] == 0: continue
        if size[a] >= 3 or size[b] >= 3:
            print("YES")
            exit()
        for c in res[a]:
            for d in res[b]:
                if c != d and b != c and a != d:
                    print("YES")
                    exit()
print("NO")
0