結果
問題 | No.1605 Matrix Shape |
ユーザー | tonyu0 |
提出日時 | 2022-09-21 13:30:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 777 ms / 2,000 ms |
コード長 | 847 bytes |
コンパイル時間 | 289 ms |
コンパイル使用メモリ | 87,068 KB |
実行使用メモリ | 120,072 KB |
最終ジャッジ日時 | 2023-08-23 19:56:06 |
合計ジャッジ時間 | 14,431 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
78,552 KB |
testcase_01 | AC | 79 ms
78,616 KB |
testcase_02 | AC | 75 ms
74,064 KB |
testcase_03 | AC | 76 ms
78,556 KB |
testcase_04 | AC | 74 ms
74,328 KB |
testcase_05 | AC | 80 ms
78,468 KB |
testcase_06 | AC | 79 ms
78,568 KB |
testcase_07 | AC | 73 ms
74,236 KB |
testcase_08 | AC | 78 ms
78,596 KB |
testcase_09 | AC | 79 ms
78,460 KB |
testcase_10 | AC | 81 ms
78,740 KB |
testcase_11 | AC | 81 ms
78,572 KB |
testcase_12 | AC | 81 ms
78,512 KB |
testcase_13 | AC | 81 ms
78,652 KB |
testcase_14 | AC | 82 ms
78,552 KB |
testcase_15 | AC | 82 ms
78,460 KB |
testcase_16 | AC | 82 ms
78,740 KB |
testcase_17 | AC | 81 ms
78,568 KB |
testcase_18 | AC | 83 ms
78,476 KB |
testcase_19 | AC | 659 ms
120,068 KB |
testcase_20 | AC | 765 ms
111,804 KB |
testcase_21 | AC | 777 ms
115,008 KB |
testcase_22 | AC | 623 ms
117,764 KB |
testcase_23 | AC | 641 ms
119,992 KB |
testcase_24 | AC | 634 ms
120,072 KB |
testcase_25 | AC | 411 ms
102,752 KB |
testcase_26 | AC | 411 ms
103,716 KB |
testcase_27 | AC | 410 ms
103,124 KB |
testcase_28 | AC | 410 ms
103,824 KB |
testcase_29 | AC | 436 ms
103,076 KB |
testcase_30 | AC | 747 ms
114,448 KB |
testcase_31 | AC | 759 ms
116,568 KB |
testcase_32 | AC | 769 ms
113,408 KB |
testcase_33 | AC | 749 ms
112,784 KB |
testcase_34 | AC | 274 ms
102,092 KB |
testcase_35 | AC | 560 ms
116,472 KB |
testcase_36 | AC | 458 ms
100,228 KB |
ソースコード
n=int(input()) M=200001 par=[-1]*M def root(a): if par[a]<0: return a return root(par[a]) def same(a, b): return root(a)==root(b) def merge(a,b): if same(a,b):return a=root(a) b=root(b) if par[a]>par[b]:a,b=b,a par[a]+=par[b] par[b]=a def sz(a): return -par[root(a)] a=[list(map(lambda x:int(x)-1, input().split())) for i in range(n)] deg = [0]*M V=set() for x,y in a: merge(x,y) V.add(x) V.add(y) deg[x]-=1 deg[y]+=1 if sz(a[0][0]) == len(V): # とりあえず連結 start=0 end=0 out=0 for x in deg: if x==1: end+=1 elif x==-1: start+=1 elif x!=0: out+=1 if out>0:print(0) elif start==1 and end==1:print(1) elif start==0 and end==0:print(len(V)) else: print(0) else: print(0)