結果

問題 No.1605 Matrix Shape
ユーザー ああいいああいい
提出日時 2021-12-28 19:36:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 40,704 KB
最終ジャッジ日時 2024-04-10 11:56:14
合計ジャッジ時間 18,166 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
13,824 KB
testcase_01 AC 97 ms
14,080 KB
testcase_02 AC 87 ms
13,952 KB
testcase_03 AC 103 ms
13,952 KB
testcase_04 WA -
testcase_05 AC 101 ms
13,952 KB
testcase_06 AC 98 ms
13,952 KB
testcase_07 AC 86 ms
13,952 KB
testcase_08 AC 103 ms
13,952 KB
testcase_09 AC 85 ms
13,952 KB
testcase_10 WA -
testcase_11 AC 85 ms
13,952 KB
testcase_12 AC 98 ms
13,952 KB
testcase_13 AC 86 ms
13,952 KB
testcase_14 WA -
testcase_15 AC 85 ms
13,952 KB
testcase_16 AC 85 ms
13,952 KB
testcase_17 AC 84 ms
13,952 KB
testcase_18 AC 86 ms
14,080 KB
testcase_19 AC 867 ms
40,576 KB
testcase_20 AC 855 ms
40,576 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 860 ms
40,576 KB
testcase_24 WA -
testcase_25 AC 804 ms
33,152 KB
testcase_26 AC 839 ms
33,280 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 842 ms
40,576 KB
testcase_31 WA -
testcase_32 AC 797 ms
40,192 KB
testcase_33 AC 819 ms
40,192 KB
testcase_34 AC 778 ms
39,680 KB
testcase_35 AC 676 ms
35,456 KB
testcase_36 AC 456 ms
27,264 KB
権限があれば一括ダウンロードができます

ソースコード

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