結果
問題 | No.1424 Ultrapalindrome |
ユーザー | kuro_B |
提出日時 | 2023-04-06 13:58:17 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,739 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 51,712 KB |
最終ジャッジ日時 | 2024-04-10 11:17:57 |
合計ジャッジ時間 | 7,241 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
11,776 KB |
testcase_01 | AC | 37 ms
11,776 KB |
testcase_02 | AC | 37 ms
11,648 KB |
testcase_03 | AC | 37 ms
11,648 KB |
testcase_04 | AC | 37 ms
11,648 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 41 ms
11,648 KB |
testcase_08 | AC | 37 ms
11,648 KB |
testcase_09 | AC | 306 ms
25,216 KB |
testcase_10 | AC | 317 ms
25,344 KB |
testcase_11 | AC | 223 ms
21,248 KB |
testcase_12 | AC | 293 ms
24,448 KB |
testcase_13 | AC | 99 ms
15,360 KB |
testcase_14 | AC | 241 ms
22,016 KB |
testcase_15 | AC | 38 ms
11,648 KB |
testcase_16 | AC | 195 ms
19,968 KB |
testcase_17 | AC | 231 ms
21,504 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 56 ms
12,800 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 388 ms
29,312 KB |
testcase_28 | AC | 321 ms
51,712 KB |
testcase_29 | AC | 316 ms
51,712 KB |
testcase_30 | WA | - |
testcase_31 | AC | 288 ms
29,824 KB |
ソースコード
###スニペット始まり### import sys, re from copy import copy, deepcopy from math import ceil, floor, sqrt,factorial, gcd, pi, degrees, radians, sin, asin, cos, acos, tan, atan2 from collections import Counter, deque, defaultdict from heapq import heapify, heappop, heappush from itertools import permutations, accumulate, product, combinations, combinations_with_replacement from bisect import bisect, bisect_left, bisect_right from functools import reduce, lru_cache from string import ascii_uppercase, ascii_lowercase from decimal import Decimal, ROUND_HALF_UP #四捨五入用 def input(): return sys.stdin.readline().rstrip('\n') #easy-testのpypyでは再帰数を下げる。 if __file__=='prog.py': sys.setrecursionlimit(10**5) else: sys.setrecursionlimit(10**6) def lcm(a, b): return a * b // gcd(a, b) #3つ以上の最大公約数/最小公倍数 def gcd_v2(l: list): return reduce(gcd, l) def lcm_v2(l: list): return reduce(lcm, l) #nPk def nPk(n, k): return factorial(n) // factorial(n - k) #逆元 def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) INF = float('inf') MOD = 10 ** 9 + 7 ###スニペット終わり### N=int(input()) graph = [[] for _ in range(N)] for _ in range(N-1): a, b = map(int, input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) # 有向グラフなら消す root_cnt=0 depths=set() visited=[False]*N def dfs(s, depth): global root_cnt visited[s]=True flag=True for v in graph[s]: if not visited[v]: flag=False dfs(v, depth+1) if flag: root_cnt+=1 depths.add(depth) dfs(0,0) if root_cnt==1: print('Yes') elif len(depths)==1 and 2 in depths: print('Yes') else: print('No')