# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
427563 |
2021-06-14T17:14:47 Z |
Tangent |
Simurgh (IOI17_simurgh) |
C++17 |
|
158 ms |
2612 KB |
#include "simurgh.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
int m = u.size();
vii seen(m);
rep(i, m) {
if (!seen[i]) {
vii curr;
vii parent(n, -1);
function<int(int)> root;
root = [&](int x) {
if (parent[x] < 0) {
return x;
}
return parent[x] = root(parent[x]);
};
vii query;
rep(j, m) {
int ru = root(u[j]), rv = root(v[j]);
if (ru == rv) {
continue;
}
if ((root(u[i]) == ru && root(v[i]) == rv) || (root(u[i]) == rv && root(v[i]) == ru)) {
curr.emplace_back(j);
seen[j] = 1;
continue;
}
if (parent[ru] < parent[rv]) {
swap(ru, rv);
}
parent[rv] += parent[ru];
parent[ru] = rv;
query.emplace_back(j);
}
if (curr.size() == 1) {
seen[curr[0]] = 2;
continue;
}
vii ans;
int amax = 0;
forin(x, curr) {
query.emplace_back(x);
ans.emplace_back(count_common_roads(query));
amax = max(amax, ans.back());
query.pop_back();
}
rep(j, curr.size()) {
if (ans[j] == amax) {
seen[curr[j]] = 2;
}
}
}
}
vii res;
rep(i, m) {
if (seen[i] == 2) {
res.emplace_back(i);
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
204 KB |
correct |
3 |
Correct |
1 ms |
204 KB |
correct |
4 |
Correct |
1 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
1 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
1 ms |
204 KB |
correct |
9 |
Correct |
1 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
1 ms |
204 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
292 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
204 KB |
correct |
3 |
Correct |
1 ms |
204 KB |
correct |
4 |
Correct |
1 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
1 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
1 ms |
204 KB |
correct |
9 |
Correct |
1 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
1 ms |
204 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
292 KB |
correct |
14 |
Correct |
14 ms |
332 KB |
correct |
15 |
Correct |
12 ms |
344 KB |
correct |
16 |
Correct |
10 ms |
332 KB |
correct |
17 |
Correct |
9 ms |
204 KB |
correct |
18 |
Correct |
4 ms |
204 KB |
correct |
19 |
Correct |
10 ms |
336 KB |
correct |
20 |
Correct |
12 ms |
296 KB |
correct |
21 |
Correct |
9 ms |
336 KB |
correct |
22 |
Correct |
5 ms |
300 KB |
correct |
23 |
Correct |
5 ms |
296 KB |
correct |
24 |
Correct |
5 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
5 ms |
204 KB |
correct |
27 |
Correct |
6 ms |
204 KB |
correct |
28 |
Correct |
2 ms |
204 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
6 ms |
204 KB |
correct |
31 |
Correct |
7 ms |
296 KB |
correct |
32 |
Correct |
8 ms |
204 KB |
correct |
33 |
Correct |
8 ms |
316 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
204 KB |
correct |
3 |
Correct |
1 ms |
204 KB |
correct |
4 |
Correct |
1 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
1 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
1 ms |
204 KB |
correct |
9 |
Correct |
1 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
1 ms |
204 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
292 KB |
correct |
14 |
Correct |
14 ms |
332 KB |
correct |
15 |
Correct |
12 ms |
344 KB |
correct |
16 |
Correct |
10 ms |
332 KB |
correct |
17 |
Correct |
9 ms |
204 KB |
correct |
18 |
Correct |
4 ms |
204 KB |
correct |
19 |
Correct |
10 ms |
336 KB |
correct |
20 |
Correct |
12 ms |
296 KB |
correct |
21 |
Correct |
9 ms |
336 KB |
correct |
22 |
Correct |
5 ms |
300 KB |
correct |
23 |
Correct |
5 ms |
296 KB |
correct |
24 |
Correct |
5 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
5 ms |
204 KB |
correct |
27 |
Correct |
6 ms |
204 KB |
correct |
28 |
Correct |
2 ms |
204 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
6 ms |
204 KB |
correct |
31 |
Correct |
7 ms |
296 KB |
correct |
32 |
Correct |
8 ms |
204 KB |
correct |
33 |
Correct |
8 ms |
316 KB |
correct |
34 |
Incorrect |
158 ms |
1108 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
204 KB |
correct |
3 |
Incorrect |
133 ms |
2612 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
204 KB |
correct |
3 |
Correct |
1 ms |
204 KB |
correct |
4 |
Correct |
1 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
1 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
1 ms |
204 KB |
correct |
9 |
Correct |
1 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
1 ms |
204 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
292 KB |
correct |
14 |
Correct |
14 ms |
332 KB |
correct |
15 |
Correct |
12 ms |
344 KB |
correct |
16 |
Correct |
10 ms |
332 KB |
correct |
17 |
Correct |
9 ms |
204 KB |
correct |
18 |
Correct |
4 ms |
204 KB |
correct |
19 |
Correct |
10 ms |
336 KB |
correct |
20 |
Correct |
12 ms |
296 KB |
correct |
21 |
Correct |
9 ms |
336 KB |
correct |
22 |
Correct |
5 ms |
300 KB |
correct |
23 |
Correct |
5 ms |
296 KB |
correct |
24 |
Correct |
5 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
5 ms |
204 KB |
correct |
27 |
Correct |
6 ms |
204 KB |
correct |
28 |
Correct |
2 ms |
204 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
6 ms |
204 KB |
correct |
31 |
Correct |
7 ms |
296 KB |
correct |
32 |
Correct |
8 ms |
204 KB |
correct |
33 |
Correct |
8 ms |
316 KB |
correct |
34 |
Incorrect |
158 ms |
1108 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |