結果

問題 No.1605 Matrix Shape
ユーザー H3PO4
提出日時 2021-07-16 21:40:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 357 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,708 KB
最終ジャッジ日時 2024-07-06 08:39:59
合計ジャッジ時間 14,772 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N = int(input())
MAX = 2 * 10 ** 5
deg = [0] * MAX
st = set()
for _ in range(N):
    H, W = (int(x) - 1 for x in input().split())
    deg[H] += 1
    deg[W] -= 1
    st.add(H)
    st.add(W)

ct = Counter(deg)
if ct[0] == MAX:
    print(len(st))
elif ct[0] == MAX - 2 and ct[-1] == ct[1] == 1:
    print(1)
else:
    print(0)
0