66462023-12-15 09:25:36KezdőAdószedőpython3Runtime error 3/30773ms67212 KiB
N,M,F = [int(i) for i in input().split()]
ut = [[] for i in range(N+1)]
for i in range(M):
    a,b = [int(i) for i in input().split()]
    ut[a].append(b)
    ut[b].append(a)
sor = [F]
volt = [False]*(N+1)
volt[F] = True
lepes = [-1]*(N+1)
lepes[F] = 0
utak = []
while sor != []:
    P = sor.pop(0)
    for x in ut[P]:
        if not volt[x]:
            sor.append(x)
            volt[x] = True
            lepes[x] = lepes[P] + 1
            utak.append([P,x])
print(len(utak))
for u in utak:
    print(*u)
            
SubtaskSumTestVerdictTimeMemory
base3/30
1Runtime error0/017ms10948 KiB
2Wrong answer0/0662ms59692 KiB
3Accepted1/117ms11732 KiB
4Wrong answer0/118ms11780 KiB
5Wrong answer0/118ms12236 KiB
6Wrong answer0/117ms12392 KiB
7Wrong answer0/118ms12504 KiB
8Wrong answer0/118ms12916 KiB
9Accepted2/223ms13692 KiB
10Wrong answer0/227ms13964 KiB
11Wrong answer0/227ms14584 KiB
12Wrong answer0/268ms17296 KiB
13Wrong answer0/2131ms22880 KiB
14Wrong answer0/2518ms53060 KiB
15Runtime error0/1591ms67212 KiB
16Wrong answer0/1579ms58928 KiB
17Runtime error0/2610ms67192 KiB
18Wrong answer0/2773ms66176 KiB
19Runtime error0/2651ms67064 KiB
20Runtime error0/2662ms66932 KiB
21Runtime error0/2652ms66832 KiB