結果
問題 | No.1424 Ultrapalindrome |
ユーザー | DrDrpilot |
提出日時 | 2022-01-30 15:19:29 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 724 bytes |
コンパイル時間 | 366 ms |
コンパイル使用メモリ | 10,824 KB |
実行使用メモリ | 441,424 KB |
最終ジャッジ日時 | 2023-09-02 01:39:00 |
合計ジャッジ時間 | 6,238 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
12,944 KB |
testcase_01 | AC | 16 ms
8,508 KB |
testcase_02 | AC | 17 ms
8,636 KB |
testcase_03 | AC | 16 ms
8,512 KB |
testcase_04 | AC | 16 ms
8,496 KB |
testcase_05 | AC | 16 ms
8,552 KB |
testcase_06 | AC | 16 ms
8,512 KB |
testcase_07 | AC | 17 ms
8,492 KB |
testcase_08 | AC | 17 ms
8,564 KB |
testcase_09 | AC | 284 ms
22,236 KB |
testcase_10 | AC | 284 ms
22,088 KB |
testcase_11 | AC | 207 ms
18,164 KB |
testcase_12 | AC | 271 ms
21,264 KB |
testcase_13 | AC | 85 ms
12,180 KB |
testcase_14 | AC | 221 ms
19,068 KB |
testcase_15 | AC | 18 ms
8,532 KB |
testcase_16 | AC | 182 ms
16,628 KB |
testcase_17 | AC | 211 ms
18,564 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
from collections import deque n=int(input()) g=[[] for _ in range(n)] in_num=[0]*n for _ in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) cnt_3=0 for i in range(n): if len(g[i])>=3: cnt_3+=1 if cnt_3>=2: print('No') elif cnt_3==0: print('Yes') else: q=deque() for i in range(n): if len(g[i])==1: q.append((i,-1,0)) D=set() while q: now,pre,d=q.popleft() for to in g[now]: if to==pre: continue if len(g[to])==1: D.add(d+1) continue q.append((to,now,d+1)) if len(D)==1: print('Yes') else: print('No')