Submission #1159877

#TimeUsernameProblemLanguageResultExecution timeMemory
1159877eliiasgDrivers (BOI24_drivers)Pypy 3
0 / 100
2114 ms763664 KiB
from heapq import * N, M, U = map(int, input().split()) roads = [tuple(reversed(list(map(int, input().split())))) for _ in range(M)] Q = sorted(tuple(reversed(list(map(int, input().split())))) + (i,) for i in range(U)) parents = [-1]*(N+1) out = [None]*U heapify(roads) for t, aq, bq, i in Q: while len(roads) > 0 and t >= roads[0][0]: _, a, b = heappop(roads) V = [a] while parents[a] != -1: a = parents[a] V.append(a) while parents[b] != -1: b = parents[b] for e in V: parents[e] = b while parents[aq] != -1: aq = parents[aq] while parents[bq] != -1: bq = parents[bq] out[i] = "TAIP" if aq == bq else "NE" print("\n".join(out))

Compilation message (stdout)

Compiling 'Main.py'...

=======
  adding: __main__.pyc (deflated 35%)

=======
#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...