## Submission #926320

# Submission time Handle Problem Language Result Execution time Memory
926320 2024-02-12T19:21:40 Z TAhmed33 Bridges (APIO19_bridges) C++
13 / 100
3000 ms 4348 KB
```#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 25;
int n, m;
struct DSU {
int sze[MAXN], par[MAXN];
void init (int n) {
for (int i = 1; i <= n; i++) {
sze[i] = 1; par[i] = i;
}
}
int find (int x) {
return par[x] == x ? x : par[x] = find(par[x]);
}
void merge (int a, int b) {
a = find(a); b = find(b);
if (a == b) return;
if (sze[a] > sze[b]) swap(a, b);
sze[b] += sze[a]; par[a] = b;
}
} cur;
array <int, 3> p[MAXN];
int main () {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int a, b, c; cin >> a >> b >> c; p[i] = {a, b, c};
}
int q; cin >> q;
while (q--) {
int t; cin >> t;
if (t == 1) {
int a, b; cin >> a >> b; p[a][2] = b;
} else {
int x, y; cin >> x >> y;
cur.init(n);
for (int i = 1; i <= m; i++) {
if (p[i][2] >= y) {
cur.merge(p[i][0], p[i][1]);
}
}
cout << cur.sze[cur.find(x)] << '\n';
}
}
}```

#### Subtask #1 13.0 / 13.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 34 ms 600 KB Output is correct
4 Correct 17 ms 604 KB Output is correct
5 Correct 17 ms 600 KB Output is correct
6 Correct 13 ms 604 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 16 ms 604 KB Output is correct
9 Correct 12 ms 348 KB Output is correct
10 Correct 14 ms 600 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 15 ms 608 KB Output is correct
13 Correct 16 ms 604 KB Output is correct
14 Correct 23 ms 860 KB Output is correct
15 Correct 24 ms 600 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct

#### Subtask #2 0 / 16.0

# Verdict Execution time Memory Grader output
1 Execution timed out 3024 ms 2920 KB Time limit exceeded
2 Halted 0 ms 0 KB -

#### Subtask #3 0 / 17.0

# Verdict Execution time Memory Grader output
1 Execution timed out 3033 ms 2488 KB Time limit exceeded
2 Halted 0 ms 0 KB -

#### Subtask #4 0 / 14.0

# Verdict Execution time Memory Grader output
1 Runtime error 56 ms 4348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #5 0 / 13.0

# Verdict Execution time Memory Grader output
1 Execution timed out 3024 ms 2920 KB Time limit exceeded
2 Halted 0 ms 0 KB -

#### Subtask #6 0 / 27.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 34 ms 600 KB Output is correct
4 Correct 17 ms 604 KB Output is correct
5 Correct 17 ms 600 KB Output is correct
6 Correct 13 ms 604 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 16 ms 604 KB Output is correct
9 Correct 12 ms 348 KB Output is correct
10 Correct 14 ms 600 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 15 ms 608 KB Output is correct
13 Correct 16 ms 604 KB Output is correct
14 Correct 23 ms 860 KB Output is correct
15 Correct 24 ms 600 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Execution timed out 3024 ms 2920 KB Time limit exceeded
19 Halted 0 ms 0 KB -