Submission #13316068


Source Code Expand

Copy
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,m=map(int,input().split())
    graph=[[] for _ in range(n)]
    for i in range(m):
        a,b=map(int,input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    queue=deque([0])
    visited=[False]*n
    visited[0]=True
    ans=[0]*n
    while queue:
        node=queue.popleft()
        for xnode in graph[node]:
            if visited[xnode]:continue
            ans[xnode]=node+1
            visited[xnode]=True
            queue.append(xnode)
    print("Yes")
    for a in ans[1:]:
        print(a)


if __name__=='__main__':
    main()

Submission Info

Submission Time
Task D - .. (Double Dots)
User charter
Language Python (3.8.2)
Score 400
Code Size 701 Byte
Status
Exec Time 434 ms
Memory 38848 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
Subtask1 400 / 400 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 21 ms 9288 KB
sample_02.txt 19 ms 9340 KB
sub1_01.txt 147 ms 21708 KB
sub1_02.txt 115 ms 18908 KB
sub1_03.txt 247 ms 30280 KB
sub1_04.txt 205 ms 26872 KB
sub1_05.txt 32 ms 10796 KB
sub1_06.txt 148 ms 22140 KB
sub1_07.txt 64 ms 14312 KB
sub1_08.txt 224 ms 27492 KB
sub1_09.txt 265 ms 31768 KB
sub1_10.txt 271 ms 31584 KB
sub1_11.txt 266 ms 31372 KB
sub1_12.txt 215 ms 25816 KB
sub1_13.txt 285 ms 31408 KB
sub1_14.txt 265 ms 31516 KB
sub1_15.txt 227 ms 27920 KB
sub1_16.txt 313 ms 29744 KB
sub1_17.txt 168 ms 21264 KB
sub1_18.txt 287 ms 29888 KB
sub1_19.txt 196 ms 25324 KB
sub1_20.txt 59 ms 11852 KB
sub1_21.txt 375 ms 35032 KB
sub1_22.txt 217 ms 23624 KB
sub1_23.txt 106 ms 16240 KB
sub1_24.txt 339 ms 34620 KB
sub1_25.txt 434 ms 38444 KB
sub1_26.txt 307 ms 32808 KB
sub1_27.txt 385 ms 32776 KB
sub1_28.txt 401 ms 37628 KB
sub1_29.txt 25 ms 9312 KB
sub1_30.txt 234 ms 21760 KB
sub1_31.txt 347 ms 34528 KB
sub1_32.txt 315 ms 33832 KB
sub1_33.txt 338 ms 34752 KB
sub1_34.txt 226 ms 23644 KB
sub1_35.txt 236 ms 23788 KB
sub1_36.txt 379 ms 38848 KB
sub1_37.txt 20 ms 9412 KB