結果

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

ソースコード

diff #

N = int(input())

C = 2 * (10 ** 5 ) + 1
hidari = [0] * C
migi = [0] * C
gyouretu = []
for _ in range(N):
    h,w = map(int,input().split())
    gyouretu.append((h,w))
    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]
        ih = i
    elif hidari[i] < migi[i]:
        migicount += migi[i] - hidari[i]
        im = i
if hidaricount > 1 or migicount > 1:
    print(0)
    exit()
if hidaricount == 1:
    for h,w in gyouretu:
        if h == ih and w == im:
            print(0)
            exit()
    print(1)
    exit()
ans = 0
for i in hidari:
    if i != 0:
        ans += 1
print(ans)
        
0