2829 | 2023-01-29 00:35:44 | VMGoJo | Rendőrségi őrjárat 2 | python3 | Runtime error 0/100 | 472ms | 103548 KiB |
from sys import stdin, stdout
def main():
n,m,l = map(int,stdin.readline().split())
nodes:list[set[int]]=[]
def addConnection(a:int,b:int):
nodes[a].add(b)
nodes[b].add(a)
for i in range(n):
nodes.append(set([i]))
tunnels:list[list[str]]=[]
for i in range(m):
a,b = map(int,stdin.readline().split())
addConnection(a,b)
#print(nodes)
patrols=stdin.readline().split()
patrols = [int(i) for i in patrols]
minutes:int=0
first_it_list:set[int]=[0]
second_it_list:set[int]
found:bool=False
#BREADTH FIRST SEARCH
def do_layer(first_it_l:set[int]) ->set[int]:
rt_set:set[int]=set([])
for i in first_it_l:
for j in nodes[i]:
rt_set.add(j)
return rt_set
def check_stuff(set_in:set[int]) ->set[int]:
global found
#print("removing: ",patrols[(minutes-1)%len(patrols)])
try:
set_in.remove(patrols[(minutes)%len(patrols)])
except:
pass
if set_in.__contains__(n-1):
stdout.write(str(minutes))
found=True
else:
return set_in
def do_min():
global minutes, first_it_list,second_it_list
minutes+=1
second_it_list=check_stuff(do_layer(first_it_list))
#print(second_it_list)
if not found:
first_it_list=second_it_list
do_min()
do_min()
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Runtime error | 18ms | 12316 KiB | ||||
2 | Runtime error | 17ms | 12696 KiB | ||||
subtask2 | 0/30 | ||||||
3 | Runtime error | 19ms | 13288 KiB | ||||
4 | Runtime error | 19ms | 13576 KiB | ||||
5 | Runtime error | 19ms | 13940 KiB | ||||
6 | Runtime error | 19ms | 13980 KiB | ||||
7 | Runtime error | 20ms | 14088 KiB | ||||
8 | Runtime error | 19ms | 14028 KiB | ||||
9 | Runtime error | 19ms | 14536 KiB | ||||
subtask3 | 0/30 | ||||||
10 | Runtime error | 356ms | 79260 KiB | ||||
11 | Runtime error | 352ms | 81476 KiB | ||||
12 | Runtime error | 455ms | 85808 KiB | ||||
13 | Runtime error | 465ms | 90864 KiB | ||||
14 | Runtime error | 375ms | 94600 KiB | ||||
subtask4 | 0/40 | ||||||
15 | Runtime error | 467ms | 97608 KiB | ||||
16 | Runtime error | 388ms | 103548 KiB | ||||
17 | Runtime error | 382ms | 100848 KiB | ||||
18 | Runtime error | 470ms | 100868 KiB | ||||
19 | Runtime error | 381ms | 100988 KiB | ||||
20 | Runtime error | 472ms | 101192 KiB | ||||
21 | Runtime error | 400ms | 101400 KiB | ||||
22 | Runtime error | 402ms | 101380 KiB | ||||
23 | Runtime error | 397ms | 97424 KiB | ||||
24 | Runtime error | 469ms | 94768 KiB |