# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766866 | 2023-06-26T08:19:28 Z | danikoynov | Simurgh (IOI17_simurgh) | C++14 | 74 ms | 1576 KB |
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; const int maxn = 510; struct disjoint_set_union { int par[maxn]; disjoint_set_union(){}; disjoint_set_union(int n) { for (int i = 0; i < n; i ++) par[i] = i; } int find_leader(int v) { if (v == par[v]) return v; return (par[v] = find_leader(par[v])); } bool is_connected(int v, int u) { return find_leader(v) == find_leader(u); } void unite(int v, int u) { v = find_leader(v); u = find_leader(u); if (v == u) return; par[v] = u; } }; int used[maxn * maxn]; vector<int> find_roads(int n, vector<int> u, vector<int> v) { vector < int > gold; int m = u.size(); while(gold.size() < n - 1) { disjoint_set_union dsu(n); int cp = n; vector < int > res; for (int edge : gold) { dsu.unite(u[edge], v[edge]); cp --; res.push_back(edge); } for (int j = 0; j < m && cp > 2; j ++) { if (!dsu.is_connected(u[j], v[j])) { dsu.unite(u[j], v[j]); cp --; res.push_back(j); } } vector < pair < int, int > > pot; for (int i = 0; i < m; i ++) { if (!dsu.is_connected(u[i], v[i])) pot.push_back({i, 0}); } int mx = -1, rd = -1; for (int i = 0; i < pot.size(); i ++) { res.push_back(pot[i].first); pot[i].second = count_common_roads(res); if (pot[i].second > mx) { mx = pot[i].second; } res.pop_back(); } for (int i = 0; i < pot.size(); i ++) { if (pot[i].second == mx) gold.push_back(pot[i].first); } } return gold; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 1 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 0 ms | 212 KB | correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 1 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 0 ms | 212 KB | correct |
14 | Correct | 2 ms | 212 KB | correct |
15 | Correct | 2 ms | 340 KB | correct |
16 | Correct | 2 ms | 212 KB | correct |
17 | Correct | 2 ms | 212 KB | correct |
18 | Correct | 1 ms | 212 KB | correct |
19 | Correct | 2 ms | 212 KB | correct |
20 | Correct | 1 ms | 212 KB | correct |
21 | Correct | 1 ms | 212 KB | correct |
22 | Correct | 2 ms | 320 KB | correct |
23 | Correct | 2 ms | 212 KB | correct |
24 | Correct | 2 ms | 312 KB | correct |
25 | Correct | 1 ms | 212 KB | correct |
26 | Correct | 2 ms | 212 KB | correct |
27 | Correct | 2 ms | 316 KB | correct |
28 | Correct | 1 ms | 212 KB | correct |
29 | Correct | 1 ms | 212 KB | correct |
30 | Correct | 3 ms | 212 KB | correct |
31 | Correct | 3 ms | 212 KB | correct |
32 | Correct | 4 ms | 212 KB | correct |
33 | Correct | 2 ms | 212 KB | correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 1 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 0 ms | 212 KB | correct |
14 | Correct | 2 ms | 212 KB | correct |
15 | Correct | 2 ms | 340 KB | correct |
16 | Correct | 2 ms | 212 KB | correct |
17 | Correct | 2 ms | 212 KB | correct |
18 | Correct | 1 ms | 212 KB | correct |
19 | Correct | 2 ms | 212 KB | correct |
20 | Correct | 1 ms | 212 KB | correct |
21 | Correct | 1 ms | 212 KB | correct |
22 | Correct | 2 ms | 320 KB | correct |
23 | Correct | 2 ms | 212 KB | correct |
24 | Correct | 2 ms | 312 KB | correct |
25 | Correct | 1 ms | 212 KB | correct |
26 | Correct | 2 ms | 212 KB | correct |
27 | Correct | 2 ms | 316 KB | correct |
28 | Correct | 1 ms | 212 KB | correct |
29 | Correct | 1 ms | 212 KB | correct |
30 | Correct | 3 ms | 212 KB | correct |
31 | Correct | 3 ms | 212 KB | correct |
32 | Correct | 4 ms | 212 KB | correct |
33 | Correct | 2 ms | 212 KB | correct |
34 | Incorrect | 74 ms | 768 KB | WA in grader: NO |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 1 ms | 212 KB | correct |
3 | Incorrect | 60 ms | 1576 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 1 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 0 ms | 212 KB | correct |
14 | Correct | 2 ms | 212 KB | correct |
15 | Correct | 2 ms | 340 KB | correct |
16 | Correct | 2 ms | 212 KB | correct |
17 | Correct | 2 ms | 212 KB | correct |
18 | Correct | 1 ms | 212 KB | correct |
19 | Correct | 2 ms | 212 KB | correct |
20 | Correct | 1 ms | 212 KB | correct |
21 | Correct | 1 ms | 212 KB | correct |
22 | Correct | 2 ms | 320 KB | correct |
23 | Correct | 2 ms | 212 KB | correct |
24 | Correct | 2 ms | 312 KB | correct |
25 | Correct | 1 ms | 212 KB | correct |
26 | Correct | 2 ms | 212 KB | correct |
27 | Correct | 2 ms | 316 KB | correct |
28 | Correct | 1 ms | 212 KB | correct |
29 | Correct | 1 ms | 212 KB | correct |
30 | Correct | 3 ms | 212 KB | correct |
31 | Correct | 3 ms | 212 KB | correct |
32 | Correct | 4 ms | 212 KB | correct |
33 | Correct | 2 ms | 212 KB | correct |
34 | Incorrect | 74 ms | 768 KB | WA in grader: NO |
35 | Halted | 0 ms | 0 KB | - |