# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254858 | 2020-07-30T18:22:10 Z | Lawliet | Bridges (APIO19_bridges) | C++17 | 3000 ms | 4348 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 50010; const int MAXM = 100010; int n, m, q; int anc[MAXN], sz[MAXN]; int U[MAXM], V[MAXM], W[MAXM]; int find(int cur) { if( anc[cur] == cur ) return cur; return anc[cur] = find( anc[cur] ); } void join(int i, int j) { i = find(i); j = find(j); if( i == j ) return; if( sz[i] < sz[j] ) swap( i , j ); anc[j] = i; sz[i] += sz[j]; } void initDSU() { for(int i = 1 ; i <= n ; i++) sz[i] = 1, anc[i] = i; } int main() { scanf("%d %d",&n,&m); for(int i = 1 ; i <= m ; i++) scanf("%d %d %d",&U[i],&V[i],&W[i]); scanf("%d",&q); for(int i = 1 ; i <= q ; i++) { int type; scanf("%d",&type); if( type == 1 ) { int ind, newW; scanf("%d %d",&ind,&newW); W[ind] = newW; } if( type == 2 ) { int s, maxW; scanf("%d %d",&s,&maxW); initDSU(); for(int j = 1 ; j <= m ; j++) if( W[j] >= maxW ) join( U[j] , V[j] ); printf("%d\n",sz[ find(s) ]); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 44 ms | 512 KB | Output is correct |
4 | Correct | 6 ms | 528 KB | Output is correct |
5 | Correct | 9 ms | 512 KB | Output is correct |
6 | Correct | 7 ms | 512 KB | Output is correct |
7 | Correct | 7 ms | 384 KB | Output is correct |
8 | Correct | 9 ms | 512 KB | Output is correct |
9 | Correct | 8 ms | 384 KB | Output is correct |
10 | Correct | 9 ms | 512 KB | Output is correct |
11 | Correct | 9 ms | 512 KB | Output is correct |
12 | Correct | 10 ms | 512 KB | Output is correct |
13 | Correct | 14 ms | 512 KB | Output is correct |
14 | Correct | 12 ms | 512 KB | Output is correct |
15 | Correct | 15 ms | 512 KB | Output is correct |
16 | Correct | 8 ms | 384 KB | Output is correct |
17 | Correct | 9 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 2948 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3070 ms | 2676 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3069 ms | 4348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 2948 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 44 ms | 512 KB | Output is correct |
4 | Correct | 6 ms | 528 KB | Output is correct |
5 | Correct | 9 ms | 512 KB | Output is correct |
6 | Correct | 7 ms | 512 KB | Output is correct |
7 | Correct | 7 ms | 384 KB | Output is correct |
8 | Correct | 9 ms | 512 KB | Output is correct |
9 | Correct | 8 ms | 384 KB | Output is correct |
10 | Correct | 9 ms | 512 KB | Output is correct |
11 | Correct | 9 ms | 512 KB | Output is correct |
12 | Correct | 10 ms | 512 KB | Output is correct |
13 | Correct | 14 ms | 512 KB | Output is correct |
14 | Correct | 12 ms | 512 KB | Output is correct |
15 | Correct | 15 ms | 512 KB | Output is correct |
16 | Correct | 8 ms | 384 KB | Output is correct |
17 | Correct | 9 ms | 384 KB | Output is correct |
18 | Execution timed out | 3063 ms | 2948 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |