#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 105;
int pr[N];
vector<int> ver[N];
int qry(vector<int> a, vector<int> b) {
return query(a.size(), b.size(), &a[0], &b[0]);
}
int find(int u) {
return pr[u] == u ? u : pr[u] = find(pr[u]);
}
int find(vector<int> a, vector<int> b) {
if (a.size() == 1) {
return a[0];
}
int l = 0, r = a.size() - 1, res = -1;
while (l <= r) {
int m = (l + r) / 2;
if (qry(vector(a.begin(), a.begin() + m + 1), b)) {
res = a[m];
r = m - 1;
} else {
l = m + 1;
}
}
return res;
}
void run(int n) {
iota(pr, pr + n, 0);
for (int i = 0; i < n; ++i) {
ver[i].push_back(i + 1);
}
for (int e = 0; e < n - 1; ++e) {
vector<int> root;
for (int i = 0; i < n; ++i) {
if (pr[i] == i) {
root.push_back(i);
}
}
int m = root.size();
vector<int> a, b;
for (int i = 0; (1 << i) < m; ++i) {
vector<int>().swap(a);
vector<int>().swap(b);
for (int j = 0; j < m; ++j) {
auto &v = j >> i & 1 ? a : b;
v.insert(v.end(), ver[root[j]].begin(), ver[root[j]].end());
}
if (qry(a, b)) {
break;
}
}
int u = find(a, b), v = find(b, a);
setRoad(u, v);
--u, --v;
for (int x : ver[pr[v]]) {
pr[x - 1] = pr[u];
ver[pr[u]].push_back(x);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
604 KB |
Ok! 104 queries used. |
2 |
Correct |
4 ms |
636 KB |
Ok! 102 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
604 KB |
Ok! 552 queries used. |
2 |
Correct |
26 ms |
632 KB |
Ok! 694 queries used. |
3 |
Correct |
26 ms |
600 KB |
Ok! 686 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
604 KB |
Ok! 1455 queries used. |
2 |
Correct |
79 ms |
640 KB |
Ok! 1709 queries used. |
3 |
Correct |
82 ms |
636 KB |
Ok! 1615 queries used. |
4 |
Correct |
78 ms |
604 KB |
Ok! 1543 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
600 KB |
Ok! 1546 queries used. |
2 |
Correct |
75 ms |
640 KB |
Ok! 1528 queries used. |
3 |
Correct |
79 ms |
644 KB |
Ok! 1709 queries used. |
4 |
Correct |
69 ms |
600 KB |
Ok! 1469 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
600 KB |
Ok! 1661 queries used. |
2 |
Correct |
79 ms |
600 KB |
Ok! 1708 queries used. |
3 |
Correct |
80 ms |
888 KB |
Ok! 1720 queries used. |
4 |
Correct |
86 ms |
628 KB |
Ok! 1650 queries used. |
5 |
Correct |
89 ms |
636 KB |
Ok! 1459 queries used. |
6 |
Correct |
74 ms |
640 KB |
Ok! 1560 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
79 ms |
628 KB |
Too many queries! 1712 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |