結果
問題 | No.1605 Matrix Shape |
ユーザー | 炭酸水 |
提出日時 | 2022-05-19 23:10:35 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,046 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 65,020 KB |
最終ジャッジ日時 | 2024-09-19 03:54:34 |
合計ジャッジ時間 | 17,978 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
16,256 KB |
testcase_01 | AC | 29 ms
10,880 KB |
testcase_02 | AC | 27 ms
10,880 KB |
testcase_03 | AC | 27 ms
10,752 KB |
testcase_04 | AC | 29 ms
10,752 KB |
testcase_05 | AC | 28 ms
10,752 KB |
testcase_06 | AC | 27 ms
10,752 KB |
testcase_07 | AC | 26 ms
10,880 KB |
testcase_08 | AC | 28 ms
10,752 KB |
testcase_09 | AC | 27 ms
10,752 KB |
testcase_10 | AC | 25 ms
10,752 KB |
testcase_11 | AC | 26 ms
10,880 KB |
testcase_12 | AC | 27 ms
10,880 KB |
testcase_13 | AC | 27 ms
10,752 KB |
testcase_14 | AC | 27 ms
10,752 KB |
testcase_15 | AC | 28 ms
10,752 KB |
testcase_16 | AC | 27 ms
10,752 KB |
testcase_17 | AC | 26 ms
10,752 KB |
testcase_18 | AC | 25 ms
10,752 KB |
testcase_19 | AC | 1,682 ms
63,060 KB |
testcase_20 | AC | 1,252 ms
37,456 KB |
testcase_21 | AC | 1,182 ms
36,424 KB |
testcase_22 | AC | 1,615 ms
61,004 KB |
testcase_23 | AC | 1,825 ms
65,020 KB |
testcase_24 | AC | 1,714 ms
62,768 KB |
testcase_25 | AC | 745 ms
11,008 KB |
testcase_26 | AC | 770 ms
10,880 KB |
testcase_27 | AC | 743 ms
11,008 KB |
testcase_28 | AC | 757 ms
10,880 KB |
testcase_29 | AC | 732 ms
11,008 KB |
testcase_30 | TLE | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
ソースコード
n = int(input()) P_C = {} C_P = {} 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 x_P = C_P.get(x, 0) y_P = C_P.get(y, 0) if x_P == 0 and y_P == 0: C_P[x] = x C_P[y] = x P_C[x] = [x, y] elif x_P == 0: C_P[x] = y_P P_C[y_P].append(x) elif y_P == 0: C_P[y] = x_P P_C[x_P].append(y) elif x_P != y_P: P = P_C[y_P].copy() for i in P: C_P[i] = x_P P_C[x_P] += P del P_C[y_P] 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 len(P_C) ==1 and count_m1 == 1 and count_p1 == 1 and count_0 == len(v) - 2: print(1) elif len(P_C) ==1 and count_0 == len(v): print(len(v)) else: print(0)