結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
13,824 KB
testcase_01 AC 119 ms
13,952 KB
testcase_02 AC 88 ms
13,952 KB
testcase_03 AC 97 ms
13,952 KB
testcase_04 WA -
testcase_05 AC 99 ms
13,952 KB
testcase_06 AC 98 ms
13,952 KB
testcase_07 AC 91 ms
14,080 KB
testcase_08 AC 98 ms
13,952 KB
testcase_09 AC 88 ms
13,952 KB
testcase_10 WA -
testcase_11 AC 85 ms
13,824 KB
testcase_12 AC 102 ms
13,952 KB
testcase_13 AC 85 ms
13,952 KB
testcase_14 WA -
testcase_15 AC 86 ms
13,952 KB
testcase_16 AC 84 ms
14,080 KB
testcase_17 AC 85 ms
13,952 KB
testcase_18 AC 88 ms
13,952 KB
testcase_19 AC 862 ms
40,576 KB
testcase_20 AC 845 ms
40,576 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 881 ms
40,704 KB
testcase_24 WA -
testcase_25 AC 811 ms
33,280 KB
testcase_26 AC 802 ms
33,408 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 822 ms
40,576 KB
testcase_31 WA -
testcase_32 AC 826 ms
40,192 KB
testcase_33 AC 830 ms
40,064 KB
testcase_34 AC 765 ms
39,552 KB
testcase_35 AC 668 ms
35,200 KB
testcase_36 AC 456 ms
27,136 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