# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1061458 |
2024-08-16T09:17:32 Z |
mc061 |
Keys (IOI21_keys) |
C++17 |
|
1681 ms |
16468 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+6;
vector<pair<int, int>> graph[N];
struct DSU {
int p[N]={};
int sz[N];
DSU() {
iota(p, p+N, 0);
fill(sz, sz+N, 1);
}
int get(int a) {
return p[a] = (a == p[a] ? a : get(p[a]));
}
void merge(int a, int b) {
int x = get(a), y = get(b);
if (x == y) return;
if (sz[x] > sz[y]) swap(x, y);
p[x] = y;
sz[y] += sz[x];
}
};
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
const int n = r.size();
const int m = u.size();
for (int i = 0; i < m; ++i) {
graph[v[i]].push_back({u[i], c[i]});
graph[u[i]].push_back({v[i], c[i]});
}
vector<int> res(n);
for (int s = 0; s < n; ++s) {
DSU d;
set<pair<int, int>> borders;
queue<int> q;
set<int> have;
set<int> have_c;
auto add = [&] (int v) {
have.insert(v);
if (!have_c.count(r[v])) {
have_c.insert(r[v]);
while (borders.size()) {
auto it = borders.lower_bound({r[v], -1});
if (it == borders.end()) break;
if (it->first == r[v]) {
d.merge(it->second, s);
if (!have.count(it->second)) {
have.insert(it->second);
q.push(it->second);
}
borders.erase(it);
continue;
}
break;
}
}
for (auto [u, w] : graph[v]) {
if (have.count(u)) continue;
if (have_c.count(w)) {
q.push(u);
have.insert(u);
d.merge(s, u);
continue;
}
borders.insert({w, u});
}
};
q.push(s);
while (!q.empty()) {
int v = q.front();
q.pop();
add(v);
}
res[s] = d.sz[d.get(s)];
}
int mn = *min_element(res.begin(), res.end());
vector<int> ret(n, 0);
for (int i = 0; i < n; ++i) {
if (res[i] == mn) ret[i] = 1;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
5 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
5 ms |
508 KB |
Output is correct |
10 |
Correct |
5 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
428 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
6 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
9 ms |
520 KB |
Output is correct |
24 |
Correct |
9 ms |
520 KB |
Output is correct |
25 |
Correct |
12 ms |
348 KB |
Output is correct |
26 |
Correct |
12 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
5 ms |
508 KB |
Output is correct |
10 |
Correct |
5 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
428 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
6 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
9 ms |
520 KB |
Output is correct |
24 |
Correct |
9 ms |
520 KB |
Output is correct |
25 |
Correct |
12 ms |
348 KB |
Output is correct |
26 |
Correct |
12 ms |
348 KB |
Output is correct |
27 |
Correct |
452 ms |
808 KB |
Output is correct |
28 |
Correct |
447 ms |
600 KB |
Output is correct |
29 |
Correct |
452 ms |
604 KB |
Output is correct |
30 |
Correct |
247 ms |
600 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
2 ms |
348 KB |
Output is correct |
34 |
Correct |
182 ms |
604 KB |
Output is correct |
35 |
Correct |
277 ms |
604 KB |
Output is correct |
36 |
Correct |
1220 ms |
600 KB |
Output is correct |
37 |
Correct |
1124 ms |
760 KB |
Output is correct |
38 |
Correct |
1681 ms |
780 KB |
Output is correct |
39 |
Correct |
1570 ms |
780 KB |
Output is correct |
40 |
Correct |
42 ms |
604 KB |
Output is correct |
41 |
Correct |
309 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
5 ms |
508 KB |
Output is correct |
10 |
Runtime error |
70 ms |
16468 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
5 ms |
508 KB |
Output is correct |
10 |
Correct |
5 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
428 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
6 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
9 ms |
520 KB |
Output is correct |
24 |
Correct |
9 ms |
520 KB |
Output is correct |
25 |
Correct |
12 ms |
348 KB |
Output is correct |
26 |
Correct |
12 ms |
348 KB |
Output is correct |
27 |
Correct |
452 ms |
808 KB |
Output is correct |
28 |
Correct |
447 ms |
600 KB |
Output is correct |
29 |
Correct |
452 ms |
604 KB |
Output is correct |
30 |
Correct |
247 ms |
600 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
2 ms |
348 KB |
Output is correct |
34 |
Correct |
182 ms |
604 KB |
Output is correct |
35 |
Correct |
277 ms |
604 KB |
Output is correct |
36 |
Correct |
1220 ms |
600 KB |
Output is correct |
37 |
Correct |
1124 ms |
760 KB |
Output is correct |
38 |
Correct |
1681 ms |
780 KB |
Output is correct |
39 |
Correct |
1570 ms |
780 KB |
Output is correct |
40 |
Correct |
42 ms |
604 KB |
Output is correct |
41 |
Correct |
309 ms |
640 KB |
Output is correct |
42 |
Runtime error |
70 ms |
16468 KB |
Execution killed with signal 11 |
43 |
Halted |
0 ms |
0 KB |
- |