Submission #35811853
Source Code Expand
from collections import deque
def C(N, X, Y, UV):
flag = [False] * (N + 1)
s = []
stop = False
def dfs(k, to):
nonlocal stop
if stop: return
else: s.append(k)
if k == to:
stop = True
return
flag[k] = True
for i in edge[k]:
if not flag[i]: dfs(i, to)
if not stop: s.pop()
edge = [[] for _ in range(N+1)]
for u, v in UV:
edge[u].append(v)
edge[v].append(u)
dfs(X, Y)
print(*s)
N, X, Y = map(int, input().split())
UV = [list(map(int, input().split())) for _ in range(N-1)]
C(N, X, Y, UV)
Submission Info
| Submission Time | |
|---|---|
| Task | C - Simple path |
| User | arakaki_tokyo |
| Language | PyPy3 (7.3.0) |
| Score | 0 |
| Code Size | 713 Byte |
| Status | RE |
| Exec Time | 548 ms |
| Memory | 200656 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 67 ms | 64852 KiB |
| example_01.txt | AC | 53 ms | 64656 KiB |
| hand_00.txt | AC | 52 ms | 64908 KiB |
| hand_01.txt | RE | 445 ms | 133560 KiB |
| hand_02.txt | AC | 442 ms | 136596 KiB |
| hand_03.txt | RE | 454 ms | 133644 KiB |
| hand_04.txt | RE | 456 ms | 133432 KiB |
| random_00.txt | AC | 532 ms | 132892 KiB |
| random_01.txt | AC | 503 ms | 132964 KiB |
| random_02.txt | AC | 495 ms | 132976 KiB |
| random_03.txt | AC | 519 ms | 133064 KiB |
| random_04.txt | AC | 539 ms | 133260 KiB |
| random_05.txt | AC | 450 ms | 133004 KiB |
| random_06.txt | AC | 453 ms | 132772 KiB |
| random_07.txt | AC | 495 ms | 132552 KiB |
| random_08.txt | AC | 493 ms | 133268 KiB |
| random_09.txt | AC | 427 ms | 134424 KiB |
| random_10.txt | AC | 434 ms | 133760 KiB |
| random_11.txt | AC | 426 ms | 134452 KiB |
| random_12.txt | RE | 545 ms | 183112 KiB |
| random_13.txt | RE | 546 ms | 196084 KiB |
| random_14.txt | RE | 548 ms | 197772 KiB |
| random_15.txt | RE | 547 ms | 196512 KiB |
| random_16.txt | RE | 537 ms | 200656 KiB |
| random_17.txt | RE | 496 ms | 154664 KiB |
| random_18.txt | RE | 469 ms | 133552 KiB |
| random_19.txt | RE | 479 ms | 137364 KiB |