結果

問題 No.1605 Matrix Shape
ユーザー convexineqconvexineq
提出日時 2021-07-16 21:46:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 82,264 KB
最終ジャッジ日時 2023-09-20 13:31:24
合計ジャッジ時間 7,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
78,496 KB
testcase_01 AC 82 ms
79,004 KB
testcase_02 AC 78 ms
78,504 KB
testcase_03 AC 82 ms
79,012 KB
testcase_04 WA -
testcase_05 AC 84 ms
79,272 KB
testcase_06 AC 82 ms
79,340 KB
testcase_07 AC 77 ms
78,544 KB
testcase_08 AC 83 ms
79,164 KB
testcase_09 AC 79 ms
78,484 KB
testcase_10 AC 78 ms
78,508 KB
testcase_11 AC 78 ms
78,508 KB
testcase_12 AC 85 ms
79,000 KB
testcase_13 AC 78 ms
78,544 KB
testcase_14 AC 79 ms
78,336 KB
testcase_15 AC 77 ms
78,500 KB
testcase_16 AC 79 ms
78,500 KB
testcase_17 AC 80 ms
78,500 KB
testcase_18 AC 78 ms
78,332 KB
testcase_19 AC 222 ms
80,476 KB
testcase_20 AC 216 ms
80,268 KB
testcase_21 AC 210 ms
80,224 KB
testcase_22 WA -
testcase_23 AC 221 ms
80,432 KB
testcase_24 AC 215 ms
80,224 KB
testcase_25 AC 184 ms
80,616 KB
testcase_26 AC 185 ms
80,620 KB
testcase_27 AC 181 ms
80,360 KB
testcase_28 WA -
testcase_29 AC 185 ms
80,200 KB
testcase_30 AC 222 ms
80,428 KB
testcase_31 AC 211 ms
80,356 KB
testcase_32 AC 218 ms
80,556 KB
testcase_33 WA -
testcase_34 AC 190 ms
82,264 KB
testcase_35 AC 191 ms
80,352 KB
testcase_36 AC 157 ms
80,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
N = 2*10**5+1
ind = [0]*N
out = [0]*N
for _ in range(n):
    h,w = map(int,input().split())
    ind[h] += 1
    out[w] += 1
nonzero = [i for i in range(N) if ind[i] != out[i]]
if len(nonzero) == 0:
    ans = sum(ind[i]+out[i] > 0 for i in range(N))
elif len(nonzero) == 2:
    i,j = nonzero
    if abs(ind[i] - out[i]) == 1:
        ans = 1
    else:
        ans = 0
else:
    ans = 0
print(ans)
0