結果

問題 No.1605 Matrix Shape
ユーザー ayaoniayaoni
提出日時 2021-09-01 21:41:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 81,860 KB
最終ジャッジ日時 2023-08-19 01:46:31
合計ジャッジ時間 7,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
78,772 KB
testcase_01 AC 67 ms
78,816 KB
testcase_02 AC 67 ms
78,852 KB
testcase_03 AC 67 ms
78,708 KB
testcase_04 WA -
testcase_05 AC 68 ms
78,680 KB
testcase_06 AC 67 ms
78,776 KB
testcase_07 AC 67 ms
78,652 KB
testcase_08 AC 67 ms
78,692 KB
testcase_09 AC 68 ms
78,884 KB
testcase_10 AC 65 ms
78,688 KB
testcase_11 AC 65 ms
74,364 KB
testcase_12 AC 67 ms
78,532 KB
testcase_13 AC 68 ms
78,808 KB
testcase_14 AC 67 ms
78,824 KB
testcase_15 AC 65 ms
78,772 KB
testcase_16 AC 67 ms
78,556 KB
testcase_17 AC 62 ms
74,408 KB
testcase_18 AC 63 ms
74,336 KB
testcase_19 AC 128 ms
80,276 KB
testcase_20 AC 121 ms
80,000 KB
testcase_21 AC 126 ms
80,132 KB
testcase_22 WA -
testcase_23 AC 136 ms
80,164 KB
testcase_24 AC 130 ms
80,368 KB
testcase_25 AC 109 ms
80,208 KB
testcase_26 AC 110 ms
80,036 KB
testcase_27 AC 106 ms
80,080 KB
testcase_28 WA -
testcase_29 AC 110 ms
80,224 KB
testcase_30 AC 123 ms
80,060 KB
testcase_31 AC 123 ms
80,172 KB
testcase_32 AC 119 ms
80,108 KB
testcase_33 WA -
testcase_34 AC 111 ms
81,860 KB
testcase_35 AC 121 ms
80,256 KB
testcase_36 AC 93 ms
80,068 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