結果

問題 No.1605 Matrix Shape
ユーザー ああいいああいい
提出日時 2021-12-28 19:31:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 628 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-10 11:49:35
合計ジャッジ時間 16,531 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 99 ms
13,824 KB
testcase_02 AC 87 ms
13,824 KB
testcase_03 AC 100 ms
13,824 KB
testcase_04 WA -
testcase_05 AC 108 ms
13,952 KB
testcase_06 AC 108 ms
13,696 KB
testcase_07 AC 85 ms
13,824 KB
testcase_08 AC 98 ms
13,824 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 84 ms
13,952 KB
testcase_12 AC 101 ms
13,824 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 84 ms
13,696 KB
testcase_16 AC 85 ms
13,952 KB
testcase_17 AC 84 ms
13,824 KB
testcase_18 AC 86 ms
13,824 KB
testcase_19 AC 770 ms
13,824 KB
testcase_20 AC 762 ms
13,952 KB
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 769 ms
13,696 KB
testcase_24 RE -
testcase_25 AC 731 ms
14,080 KB
testcase_26 AC 726 ms
13,952 KB
testcase_27 RE -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 766 ms
13,824 KB
testcase_31 RE -
testcase_32 AC 730 ms
13,824 KB
testcase_33 RE -
testcase_34 AC 711 ms
13,824 KB
testcase_35 AC 615 ms
13,824 KB
testcase_36 AC 404 ms
13,824 KB
権限があれば一括ダウンロードができます

ソースコード

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]
        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:
    if hi == mi:
        print(0)
        exit()
    print(1)
    exit()
ans = 0
for i in hidari:
    if i != 0:
        ans += 1
print(ans)
        
0