結果

問題 No.1605 Matrix Shape
ユーザー 炭酸水炭酸水
提出日時 2022-05-19 22:53:32
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 39,064 KB
最終ジャッジ日時 2023-10-19 07:15:49
合計ジャッジ時間 15,954 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,160 KB
testcase_01 AC 29 ms
10,160 KB
testcase_02 AC 29 ms
10,160 KB
testcase_03 AC 29 ms
10,160 KB
testcase_04 WA -
testcase_05 AC 28 ms
10,160 KB
testcase_06 AC 29 ms
10,160 KB
testcase_07 AC 29 ms
10,160 KB
testcase_08 AC 29 ms
10,160 KB
testcase_09 AC 29 ms
10,160 KB
testcase_10 AC 29 ms
10,160 KB
testcase_11 AC 29 ms
10,160 KB
testcase_12 AC 28 ms
10,160 KB
testcase_13 AC 29 ms
10,160 KB
testcase_14 AC 29 ms
10,160 KB
testcase_15 AC 28 ms
10,160 KB
testcase_16 AC 29 ms
10,160 KB
testcase_17 AC 29 ms
10,160 KB
testcase_18 AC 29 ms
10,160 KB
testcase_19 AC 883 ms
39,064 KB
testcase_20 AC 829 ms
24,604 KB
testcase_21 AC 833 ms
24,604 KB
testcase_22 WA -
testcase_23 AC 905 ms
39,064 KB
testcase_24 AC 887 ms
39,064 KB
testcase_25 AC 637 ms
10,236 KB
testcase_26 AC 640 ms
10,236 KB
testcase_27 AC 643 ms
10,236 KB
testcase_28 WA -
testcase_29 AC 637 ms
10,236 KB
testcase_30 AC 827 ms
24,604 KB
testcase_31 AC 830 ms
24,604 KB
testcase_32 AC 752 ms
17,384 KB
testcase_33 WA -
testcase_34 AC 636 ms
10,180 KB
testcase_35 AC 684 ms
32,584 KB
testcase_36 AC 431 ms
24,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

v = set()
z = {}
for _ in range(n):
    x, y = map(int, input().split())
    if x in v:
        z[x] += 1
    else:
        v.add(x)
        z[x] = 1
    if y in v:
        z[y] -= 1
    else:
        v.add(y)
        z[y] = -1

count_p1 = 0
count_0 = 0
count_m1 = 0

for i in v:
    if z[i] == 0:
        count_0 += 1
    elif z[i] == 1:
        count_p1 += 1
    elif z[i] == -1:
        count_m1 += 1

if count_m1 == 1 and count_p1 == 1 and count_0 == len(v) - 2:
    print(1)
elif count_0 == len(v):
    print(len(v))
else:
    print(0)
0