Submission #971514

#TimeUsernameProblemLanguageResultExecution timeMemory
971514Lcc735Toll (BOI17_toll)Cpython 3
0 / 100
3057 ms24328 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...