Submission #63049269


Source Code Expand

Copy
n=int(input())
g=[[]for _ in range(n)]
for _ in range(n-1):
a,b=map(lambda x:int(x)-1,input().split())
g[a].append(b)
g[b].append(a)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
for i in range(n):
g[i].sort(key=lambda x:len(g[x]),reverse=True)
start=-1
for i in range(n):
if len(g[i])>=4:
start=i;break
if start==-1:
exit(print(start))
import sys
sys.setrecursionlimit(10**6)
def dfs(now,prev=-1):
cnt=1
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
n=int(input())
g=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(lambda x:int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

for i in range(n):
    g[i].sort(key=lambda x:len(g[x]),reverse=True)
start=-1
for i in range(n):
    if len(g[i])>=4:
        start=i;break
if start==-1:
    exit(print(start))
import sys
sys.setrecursionlimit(10**6)
def dfs(now,prev=-1):
    cnt=1
    for v in g[now]:
        if len(g[v])<4:break
        if v==prev:continue
        cnt+=dfs(v,now)
    return cnt
m=dfs(start)
print(m*3+2)

Submission Info

Submission Time
Task F - Alkane
User juten
Language Python (PyPy 3.10-v7.3.12)
Score 0
Code Size 625 Byte
Status WA
Exec Time 443 ms
Memory 162720 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 39
WA × 20
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All hand00.txt, hand01.txt, hand02.txt, hand03.txt, sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt, testcase44.txt, testcase45.txt, testcase46.txt, testcase47.txt, testcase48.txt, testcase49.txt, testcase50.txt, testcase51.txt
Case Name Status Exec Time Memory
hand00.txt AC 53 ms 76836 KB
hand01.txt AC 53 ms 76544 KB
hand02.txt AC 85 ms 76532 KB
hand03.txt AC 55 ms 76468 KB
sample00.txt AC 54 ms 76636 KB
sample01.txt AC 55 ms 76748 KB
sample02.txt AC 54 ms 76372 KB
testcase00.txt AC 54 ms 76588 KB
testcase01.txt AC 54 ms 76716 KB
testcase02.txt AC 55 ms 76728 KB
testcase03.txt AC 55 ms 76604 KB
testcase04.txt AC 328 ms 113540 KB
testcase05.txt AC 355 ms 116380 KB
testcase06.txt AC 175 ms 95896 KB
testcase07.txt AC 354 ms 116180 KB
testcase08.txt AC 175 ms 95508 KB
testcase09.txt AC 356 ms 116832 KB
testcase10.txt AC 217 ms 112776 KB
testcase11.txt AC 443 ms 162720 KB
testcase12.txt AC 218 ms 100904 KB
testcase13.txt AC 360 ms 116728 KB
testcase14.txt AC 296 ms 110036 KB
testcase15.txt AC 361 ms 116852 KB
testcase16.txt AC 340 ms 114460 KB
testcase17.txt AC 369 ms 116256 KB
testcase18.txt AC 356 ms 116764 KB
testcase19.txt AC 371 ms 116716 KB
testcase20.txt AC 231 ms 103136 KB
testcase21.txt AC 357 ms 116624 KB
testcase22.txt AC 230 ms 105684 KB
testcase23.txt AC 319 ms 115728 KB
testcase24.txt AC 316 ms 115004 KB
testcase25.txt AC 333 ms 116304 KB
testcase26.txt AC 209 ms 101248 KB
testcase27.txt AC 338 ms 116072 KB
testcase28.txt AC 315 ms 113508 KB
testcase29.txt AC 332 ms 116496 KB
testcase30.txt AC 299 ms 111808 KB
testcase31.txt AC 335 ms 116380 KB
testcase32.txt WA 209 ms 101816 KB
testcase33.txt WA 339 ms 117212 KB
testcase34.txt WA 134 ms 90876 KB
testcase35.txt WA 351 ms 117440 KB
testcase36.txt WA 193 ms 100244 KB
testcase37.txt WA 337 ms 117656 KB
testcase38.txt WA 240 ms 104204 KB
testcase39.txt WA 356 ms 117404 KB
testcase40.txt WA 288 ms 111072 KB
testcase41.txt WA 362 ms 117892 KB
testcase42.txt WA 187 ms 98172 KB
testcase43.txt WA 357 ms 117460 KB
testcase44.txt WA 292 ms 111364 KB
testcase45.txt WA 340 ms 117584 KB
testcase46.txt WA 174 ms 97100 KB
testcase47.txt WA 340 ms 117712 KB
testcase48.txt WA 154 ms 93244 KB
testcase49.txt WA 352 ms 117472 KB
testcase50.txt WA 338 ms 116168 KB
testcase51.txt WA 336 ms 117660 KB


2025-05-05 (Mon)
15:12:40 +09:00