結果

問題 No.1605 Matrix Shape
ユーザー trineutrontrineutron
提出日時 2021-07-16 21:40:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 646 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 12,888 KB
最終ジャッジ日時 2023-09-20 13:25:02
合計ジャッジ時間 16,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
12,792 KB
testcase_01 AC 138 ms
12,764 KB
testcase_02 AC 139 ms
12,760 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 132 ms
12,640 KB
testcase_06 AC 139 ms
12,760 KB
testcase_07 AC 135 ms
12,780 KB
testcase_08 AC 136 ms
12,832 KB
testcase_09 AC 138 ms
12,876 KB
testcase_10 AC 137 ms
12,636 KB
testcase_11 AC 25 ms
12,784 KB
testcase_12 AC 136 ms
12,888 KB
testcase_13 AC 137 ms
12,704 KB
testcase_14 AC 133 ms
12,768 KB
testcase_15 AC 135 ms
12,776 KB
testcase_16 AC 138 ms
12,712 KB
testcase_17 AC 25 ms
12,704 KB
testcase_18 AC 24 ms
12,708 KB
testcase_19 AC 760 ms
12,708 KB
testcase_20 AC 748 ms
12,780 KB
testcase_21 AC 738 ms
12,788 KB
testcase_22 WA -
testcase_23 AC 759 ms
12,784 KB
testcase_24 AC 740 ms
12,856 KB
testcase_25 AC 726 ms
12,784 KB
testcase_26 AC 730 ms
12,688 KB
testcase_27 AC 726 ms
12,796 KB
testcase_28 AC 612 ms
12,764 KB
testcase_29 AC 715 ms
12,740 KB
testcase_30 AC 738 ms
12,692 KB
testcase_31 AC 735 ms
12,636 KB
testcase_32 AC 718 ms
12,732 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 624 ms
12,704 KB
testcase_36 AC 324 ms
12,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
count_h = [0] * 200000
count_w = [0] * 200000
loop = [0] * 200000
for i in range(n):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    if h == w:
        loop[h] += 1
    else:
        count_h[h] += 1
        count_w[w] += 1
ans = 0
diff = []
for i in range(200000):
    if abs(count_h[i] - count_w[i]) > 1:
        print(0)
        exit()
    elif count_h[i] == 0 and count_w[i] == 0 and loop[i] != 0:
        print(0)
        exit()
    elif count_h[i] != count_w[i]:
        diff.append(i)
    elif count_h[i]:
        ans += 1
if len(diff) > 2:
    print(0)
    exit()
if diff:
    print(1)
else:
    print(ans)
0