結果

問題 No.1605 Matrix Shape
ユーザー ああいい
提出日時 2021-12-28 19:29:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-10-02 13:46:16
合計ジャッジ時間 17,346 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

C = 2 * (10 ** 5 ) + 1
hidari = [0] * C
migi = [0] * C
for _ in range(N):
    h,w = map(int,input().split())
    hidari[h] += 1
    migi[w] += 1
import sys
hidaricount = 0
migicount = 0
for i in range(1,C):
    if hidari[i] > migi[i]:
        hidaricount += hidari[i] - migi[i]
    elif hidari[i] < migi[i]:
        migicount += migi[i] - hidari[i]
if hidaricount > 1 or migicount > 1:
    print(0)
    exit()
if hidaricount == 1:
    print(1)
    exit()
ans = 0
for i in hidari:
    if i != 0:
        ans += 1
print(ans)
        
0