結果

問題 No.408 五輪ピック
ユーザー convexineqconvexineq
提出日時 2021-02-10 00:45:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 245 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 25,624 KB
最終ジャッジ日時 2023-09-21 12:10:59
合計ジャッジ時間 6,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,252 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 17 ms
7,820 KB
testcase_03 AC 17 ms
8,164 KB
testcase_04 AC 16 ms
8,104 KB
testcase_05 AC 192 ms
18,056 KB
testcase_06 AC 135 ms
19,400 KB
testcase_07 AC 184 ms
21,196 KB
testcase_08 AC 155 ms
16,856 KB
testcase_09 AC 147 ms
15,852 KB
testcase_10 AC 126 ms
17,136 KB
testcase_11 AC 122 ms
16,732 KB
testcase_12 AC 205 ms
21,960 KB
testcase_13 AC 193 ms
17,932 KB
testcase_14 AC 56 ms
11,668 KB
testcase_15 AC 189 ms
14,036 KB
testcase_16 AC 211 ms
15,624 KB
testcase_17 AC 225 ms
22,420 KB
testcase_18 AC 234 ms
19,636 KB
testcase_19 AC 244 ms
22,760 KB
testcase_20 AC 76 ms
14,256 KB
testcase_21 AC 50 ms
11,396 KB
testcase_22 AC 122 ms
18,528 KB
testcase_23 AC 239 ms
23,020 KB
testcase_24 AC 201 ms
20,864 KB
testcase_25 AC 180 ms
15,312 KB
testcase_26 AC 245 ms
25,624 KB
testcase_27 AC 190 ms
15,184 KB
testcase_28 AC 136 ms
16,984 KB
testcase_29 AC 134 ms
17,092 KB
testcase_30 AC 16 ms
7,808 KB
testcase_31 AC 16 ms
7,824 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