Submission #971514

# Submission time Handle Problem Language Result Execution time Memory
971514 2024-04-28T17:34:03 Z Lcc735 Toll (BOI17_toll) Python 3
0 / 100
3000 ms 24328 KB
k,n,m,o=map(int,input().split())
caminos=[]
for i in range(n):
    caminos.append([])
for i in range(m):
    a,b,t=map(int,input().split())
    caminos[b].append([a,t])
def llegar(b,t,camino,caminos,a,opciones):
    if(len(camino)!=0):
        for i in camino:
            if(i[0]==a):
                opciones.append(t+i[1])
            opciones=llegar(i[0],t+i[1],caminos[i[0]],caminos,a,opciones)
    return opciones
    
for i in range(o):
    t=0
    a,b=map(int,input().split())
    opciones=[]
    opciones=llegar(b,t,caminos[b],caminos,a,opciones)
    if(len(opciones)==0):
        print('-1')
    else:
        print(min(opciones))
# Verdict Execution time Memory Grader output
1 Runtime error 144 ms 17124 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 256 ms 24328 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
2 Correct 10 ms 2864 KB Output is correct
3 Correct 10 ms 2908 KB Output is correct
4 Correct 11 ms 2908 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 14 ms 3212 KB Output is correct
7 Execution timed out 3057 ms 3676 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
2 Correct 10 ms 2864 KB Output is correct
3 Correct 10 ms 2908 KB Output is correct
4 Correct 11 ms 2908 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 14 ms 3212 KB Output is correct
7 Execution timed out 3057 ms 3676 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 144 ms 17124 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -