結果

問題 No.408 五輪ピック
ユーザー maspymaspy
提出日時 2020-03-28 00:58:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 925 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 28,268 KB
最終ジャッジ日時 2023-08-30 17:12:01
合計ジャッジ時間 5,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 17 ms
8,240 KB
testcase_02 AC 16 ms
8,160 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 83 ms
17,612 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 71 ms
15,884 KB
testcase_11 AC 69 ms
15,164 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 35 ms
11,084 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 46 ms
13,408 KB
testcase_21 AC 33 ms
11,016 KB
testcase_22 AC 74 ms
17,096 KB
testcase_23 WA -
testcase_24 AC 122 ms
23,408 KB
testcase_25 WA -
testcase_26 AC 150 ms
21,952 KB
testcase_27 AC 206 ms
19,748 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 17 ms
8,240 KB
testcase_31 AC 17 ms
8,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools

N, M = map(int, readline().split())
m = map(int, read().split())
AB = tuple(zip(m, m))

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


dist_1 = set(graph[1])
parent = [set() for _ in range(N + 1)]
for u in dist_1:
    for v in graph[u]:
        if u == 1:
            continue
        parent[v].add(u)


def solve():
    for v1, v2 in AB:
        if v1 == 1 or v2 == 1:
            continue
        for u1, u2 in itertools.product(parent[v1], parent[v2]):
            if u1 == v2:
                continue
            if u2 == v1:
                continue
            if u1 == u2:
                continue
            print(v1, v2, u1, u2)
            return True
    return False


print('YES' if solve() else 'NO')
0