結果

問題 No.1605 Matrix Shape
ユーザー ayaoniayaoni
提出日時 2021-09-01 21:41:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 80,732 KB
最終ジャッジ日時 2024-05-06 08:55:43
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
62,112 KB
testcase_01 AC 45 ms
61,828 KB
testcase_02 AC 43 ms
61,784 KB
testcase_03 AC 44 ms
61,172 KB
testcase_04 WA -
testcase_05 AC 43 ms
61,220 KB
testcase_06 AC 43 ms
61,616 KB
testcase_07 AC 44 ms
61,480 KB
testcase_08 AC 44 ms
61,612 KB
testcase_09 AC 43 ms
61,100 KB
testcase_10 AC 44 ms
61,464 KB
testcase_11 AC 41 ms
56,280 KB
testcase_12 AC 44 ms
61,428 KB
testcase_13 AC 45 ms
62,548 KB
testcase_14 AC 44 ms
61,504 KB
testcase_15 AC 44 ms
61,684 KB
testcase_16 AC 43 ms
61,288 KB
testcase_17 AC 40 ms
55,204 KB
testcase_18 AC 40 ms
55,664 KB
testcase_19 AC 124 ms
78,584 KB
testcase_20 AC 116 ms
78,908 KB
testcase_21 AC 118 ms
78,760 KB
testcase_22 WA -
testcase_23 AC 124 ms
79,112 KB
testcase_24 AC 126 ms
79,160 KB
testcase_25 AC 95 ms
78,696 KB
testcase_26 AC 98 ms
79,224 KB
testcase_27 AC 93 ms
78,736 KB
testcase_28 WA -
testcase_29 AC 95 ms
78,848 KB
testcase_30 AC 117 ms
78,696 KB
testcase_31 AC 122 ms
79,320 KB
testcase_32 AC 109 ms
78,704 KB
testcase_33 WA -
testcase_34 AC 99 ms
80,732 KB
testcase_35 AC 115 ms
78,940 KB
testcase_36 AC 84 ms
78,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()

M = 2*10**5
in_deg = [0]*(M+1)
out_deg = [0]*(M+1)
for _ in range(N):
    H,W = MI()
    out_deg[H] += 1
    in_deg[W] += 1

a,b,c = 0,0,0
for i in range(1,M+1):
    if in_deg[i] == out_deg[i]:
        if in_deg[i]:
            a += 1
    elif in_deg[i] == out_deg[i]+1:
        b += 1
    elif in_deg[i]+1 == out_deg[i]:
        c += 1
    else:
        print(0)
        exit()

if b > 1 or c > 1 or b != c:
    print(0)
    exit()

if b:
    print(1)
else:
    print(a)
0