# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
570313 |
2022-05-29T08:06:16 Z |
600Mihnea |
ICC (CEOI16_icc) |
C++17 |
|
181 ms |
644 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
mt19937 rng((long long) (new char));
int get(vector<int> a, vector<int> b) {
if (a.empty() || b.empty()) {
return 0;
}
return query((int) a.size(), (int) b.size(), a.data(), b.data());
}
vector<int> operator + (vector<int> a, vector<int> b) {
for (auto &x : b) {
a.push_back(x);
}
return a;
}
const int N = 100 + 7;
int t[N];
int get_root(int a) {
if (t[a] == a) {
return a;
} else {
return t[a] = get_root(t[a]);
}
}
void join(int a, int b) {
t[get_root(a)] = get_root(b);
}
void run(int n) {
for (int i = 1; i <= n; i++) {
t[i] = i;
}
for (int step = 1; step <= n - 1; step++) {
vector<vector<int>> comps;
for (int i = 1; i <= n; i++) {
if (get_root(i) == i) {
vector<int> currentComp;
for (int j = 1; j <= n; j++) {
if (get_root(j) == i) {
currentComp.push_back(j);
}
}
comps.push_back(currentComp);
}
}
assert((int) comps.size() == n - step + 1);
assert((int) comps.size() >= 2);
vector<int> p1, p2;
while (1) {
p1.clear();
p2.clear();
for (auto &comp : comps) {
if (rng() & 1) {
p1 = p1 + comp;
} else {
p2 = p2 + comp;
}
}
assert((int) p1.size() + (int) p2.size() == n);
if (get(p1, p2) == 1) {
break;
}
}
while ((int) p1.size() > 1 || (int) p2.size() > 1) {
shuffle(p1.begin(), p1.end(), rng);
shuffle(p2.begin(), p2.end(), rng);
if ((int) p2.size() < (int) p1.size()) {
swap(p1, p2);
}
assert((int) p1.size() <= (int) p2.size());
vector<int> X(p2.begin(), p2.begin() + (int)p2.size() / 2), Y(p2.begin() + (int) p2.size() / 2, p2.end());
assert((int) X.size() + (int) Y.size() == (int) p2.size());
if (get(p1, X)) {
p2 = X;
} else {
p2 = Y;
}
}
assert((int) p1.size() == 1 && (int) p2.size() == 1);
join(p1[0], p2[0]);
setRoad(p1[0], p2[0]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Ok! 108 queries used. |
2 |
Correct |
6 ms |
468 KB |
Ok! 111 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
492 KB |
Ok! 546 queries used. |
2 |
Correct |
51 ms |
492 KB |
Ok! 879 queries used. |
3 |
Correct |
43 ms |
500 KB |
Ok! 802 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
524 KB |
Ok! 1555 queries used. |
2 |
Correct |
181 ms |
644 KB |
Ok! 2147 queries used. |
3 |
Correct |
126 ms |
508 KB |
Ok! 1694 queries used. |
4 |
Correct |
129 ms |
508 KB |
Ok! 1740 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
139 ms |
508 KB |
Ok! 1707 queries used. |
2 |
Correct |
126 ms |
588 KB |
Ok! 1701 queries used. |
3 |
Correct |
137 ms |
532 KB |
Ok! 1861 queries used. |
4 |
Correct |
116 ms |
640 KB |
Ok! 1549 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
149 ms |
468 KB |
Too many queries! 1916 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
528 KB |
Too many queries! 1927 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |