結果

問題 No.2202 贅沢てりたまチキン
ユーザー FromBooskaFromBooska
提出日時 2023-03-05 16:36:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 807 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 310,044 KB
最終ジャッジ日時 2023-10-18 04:56:09
合計ジャッジ時間 5,776 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
60,052 KB
testcase_01 AC 41 ms
55,568 KB
testcase_02 AC 41 ms
55,568 KB
testcase_03 AC 42 ms
55,568 KB
testcase_04 AC 41 ms
55,568 KB
testcase_05 AC 42 ms
55,568 KB
testcase_06 AC 42 ms
55,568 KB
testcase_07 AC 42 ms
55,568 KB
testcase_08 AC 42 ms
55,568 KB
testcase_09 AC 41 ms
55,568 KB
testcase_10 AC 52 ms
75,536 KB
testcase_11 AC 42 ms
55,568 KB
testcase_12 AC 41 ms
55,568 KB
testcase_13 AC 42 ms
55,568 KB
testcase_14 AC 272 ms
123,648 KB
testcase_15 AC 275 ms
123,748 KB
testcase_16 AC 301 ms
137,304 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 頂点倍化

N, M = map(int, input().split())
edges = [[] for i in range(N*2+1)]
for i in range(M):
    a, b = map(int, input().split())
    edges[a].append(b+N)
    edges[b+N].append(a)
    edges[b].append(a+N)
    edges[a+N].append(b)

from collections import deque
def bfs(start, goal):
    que = deque()
    que.append(start)
    visited = [0]*(N*2+1)
    visited[start] = 0
    while que:
        current = que.popleft()
        if current == goal:
            return 1
        for nxt in edges[current]:
            if visited[nxt] == 0:
                visited[nxt] = 1
                que.append(nxt)
    return 0
    
test = 1
for i in range(1, N+1):
    calc = bfs(i, i+N)
    #print(i, calc)
    test *= calc
    if test == 0:
        break
if test == 1:
    print('Yes')
else:
    print('No')
0