結果

問題 No.1605 Matrix Shape
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-07-17 11:40:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 839,460 KB
最終ジャッジ日時 2023-09-21 04:35:54
合計ジャッジ時間 16,393 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
80,664 KB
testcase_01 WA -
testcase_02 AC 83 ms
79,592 KB
testcase_03 WA -
testcase_04 AC 82 ms
80,120 KB
testcase_05 AC 88 ms
80,876 KB
testcase_06 WA -
testcase_07 AC 84 ms
79,888 KB
testcase_08 WA -
testcase_09 AC 88 ms
80,504 KB
testcase_10 AC 90 ms
80,488 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 89 ms
80,432 KB
testcase_14 AC 89 ms
80,688 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,089 ms
286,460 KB
testcase_20 WA -
testcase_21 AC 862 ms
200,040 KB
testcase_22 AC 758 ms
199,020 KB
testcase_23 WA -
testcase_24 AC 959 ms
214,512 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 238 ms
101,116 KB
testcase_28 AC 237 ms
100,700 KB
testcase_29 AC 241 ms
100,696 KB
testcase_30 WA -
testcase_31 AC 538 ms
106,340 KB
testcase_32 WA -
testcase_33 AC 539 ms
131,408 KB
testcase_34 WA -
testcase_35 MLE -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 7)
n = int(input())
cnt = [0 for i in range(2 * 10 ** 5)]
G = [[] for i in range(2 * 10 ** 5)]
s = set()
for _ in range(n):
    h, w = map(int, input().split())
    G[h - 1].append(w - 1)
    G[w - 1].append(h - 1)
    cnt[h - 1] += 1
    cnt[w - 1] -= 1
    s.add(h - 1)
    s.add(w - 1)
vis = [0] * (2 * 10 ** 5)
def dfs(v):
    vis[v] = 1
    for u in G[v]:
        if not vis[u]: dfs(u)
dfs(0)
if not all(vis[i] for i in s): exit(print(0))
tmp = sum(abs(cnt[i]) for i in range(2 * 10 ** 5)) 
if tmp == 0: print(n)
else: print(1)
0