結果

問題 No.2202 贅沢てりたまチキン
ユーザー kenshi4041kenshi4041
提出日時 2023-02-03 22:39:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 734 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 192,748 KB
最終ジャッジ日時 2023-09-15 18:48:21
合計ジャッジ時間 12,227 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
15,724 KB
testcase_01 AC 18 ms
8,468 KB
testcase_02 AC 18 ms
8,540 KB
testcase_03 AC 18 ms
8,508 KB
testcase_04 AC 18 ms
8,696 KB
testcase_05 AC 18 ms
8,684 KB
testcase_06 AC 18 ms
8,632 KB
testcase_07 AC 19 ms
8,656 KB
testcase_08 AC 18 ms
8,664 KB
testcase_09 AC 18 ms
8,544 KB
testcase_10 AC 18 ms
8,604 KB
testcase_11 AC 18 ms
8,464 KB
testcase_12 AC 18 ms
8,544 KB
testcase_13 AC 18 ms
8,668 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from collections import defaultdict

n, m = (int(x) for x in input().split())
l = defaultdict(list)
for i in range(m):
    a, b = (int(x) for x in input().split())
    a -= 1
    b -= 1
    l[str(a)+"up"].append(str(b)+"down")
    l[str(a)+"down"].append(str(b)+"up")
    l[str(b)+"up"].append(str(a)+"down")
    l[str(b)+"down"].append(str(a)+"up")

def bfs(u):
    queue = deque([u])
    S = set(); S.add(u)
    while queue:
        v = queue.popleft()
        for i in l[v]:
            if not i in S:
                queue.append(i)
                S.add(i)
    return S


for i in range(n):
    d = bfs(str(i) + "up")
    if str(i) + "down" not in d:
        print("No")
        exit()

print("Yes")
0