제출 #1283229

#제출 시각아이디문제언어결과실행 시간메모리
1283229dev_pandey20Drivers (BOI24_drivers)Pypy 3
컴파일 에러
0 ms0 KiB
def solve(): read N, M, U edges = [] # list of (t, u, v) for i in range(M): u, v, t = map(int, input().split()) edges.append((t, u-1, v-1)) queries = [] for qi in range(U): a, b, p = map(int, input().split()) queries.append((p, a-1, b-1, qi)) # Sort edges by weight edges.sort(key=lambda e: e[0]) # Prepare DSU structures for thresholds 1..10 dsus = [ DSU(N) for _ in range(11) ] # index by p from 0..10 (we use 1..10) # Alternatively, you can use one DSU and carry over, copying parent arrays idx = 0 for thr in range(1, 11): # inherit from previous threshold if thr > 1: dsus[thr].parent = dsus[thr-1].parent.copy() dsus[thr].rank = dsus[thr-1].rank.copy() # add edges with weight == thr while idx < len(edges) and edges[idx][0] == thr: _, u, v = edges[idx] dsus[thr].union(u, v) idx += 1 # Process queries ans = [False] * U for p, a, b, qi in queries: if dsus[p].find(a) == dsus[p].find(b): ans[qi] = True for i in range(U): print("TAIP" if ans[i] else "NE")

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'Main.py'...
***   File "Main.py", line 2
    read N, M, U
    ^
SyntaxError: invalid syntax. Perhaps you forgot a comma?


=======