結果

問題 No.1605 Matrix Shape
ユーザー convexineq
提出日時 2021-07-16 21:46:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 80,768 KB
最終ジャッジ日時 2024-07-06 08:47:22
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
N = 2*10**5+1
ind = [0]*N
out = [0]*N
for _ in range(n):
    h,w = map(int,input().split())
    ind[h] += 1
    out[w] += 1
nonzero = [i for i in range(N) if ind[i] != out[i]]
if len(nonzero) == 0:
    ans = sum(ind[i]+out[i] > 0 for i in range(N))
elif len(nonzero) == 2:
    i,j = nonzero
    if abs(ind[i] - out[i]) == 1:
        ans = 1
    else:
        ans = 0
else:
    ans = 0
print(ans)
0