Submission #13351843


Source Code Expand

Copy
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())

G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)

print('Yes')
print(*par[2:], sep='\n')

Submission Info

Submission Time
Task D - .. (Double Dots)
User maspy
Language Python (3.8.2)
Score 400
Code Size 621 Byte
Status AC
Exec Time 440 ms
Memory 54756 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 39
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt
Case Name Status Exec Time Memory
sample_01.txt AC 19 ms 9412 KB
sample_02.txt AC 20 ms 9256 KB
sub1_01.txt AC 145 ms 25836 KB
sub1_02.txt AC 115 ms 21840 KB
sub1_03.txt AC 252 ms 36540 KB
sub1_04.txt AC 207 ms 32244 KB
sub1_05.txt AC 31 ms 11036 KB
sub1_06.txt AC 151 ms 26084 KB
sub1_07.txt AC 62 ms 15676 KB
sub1_08.txt AC 235 ms 31776 KB
sub1_09.txt AC 276 ms 38656 KB
sub1_10.txt AC 278 ms 38720 KB
sub1_11.txt AC 279 ms 38584 KB
sub1_12.txt AC 209 ms 30320 KB
sub1_13.txt AC 281 ms 38556 KB
sub1_14.txt AC 272 ms 38492 KB
sub1_15.txt AC 238 ms 32068 KB
sub1_16.txt AC 307 ms 51224 KB
sub1_17.txt AC 172 ms 29468 KB
sub1_18.txt AC 295 ms 39116 KB
sub1_19.txt AC 202 ms 31464 KB
sub1_20.txt AC 50 ms 15968 KB
sub1_21.txt AC 377 ms 47720 KB
sub1_22.txt AC 189 ms 40376 KB
sub1_23.txt AC 92 ms 23828 KB
sub1_24.txt AC 381 ms 46096 KB
sub1_25.txt AC 440 ms 53716 KB
sub1_26.txt AC 326 ms 41536 KB
sub1_27.txt AC 391 ms 47588 KB
sub1_28.txt AC 426 ms 51576 KB
sub1_29.txt AC 23 ms 9684 KB
sub1_30.txt AC 198 ms 43356 KB
sub1_31.txt AC 348 ms 47128 KB
sub1_32.txt AC 329 ms 44296 KB
sub1_33.txt AC 357 ms 47124 KB
sub1_34.txt AC 192 ms 42796 KB
sub1_35.txt AC 199 ms 42524 KB
sub1_36.txt AC 371 ms 54756 KB
sub1_37.txt AC 23 ms 9456 KB