# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1092840 |
2024-09-25T08:37:55 Z |
Fran |
ICC (CEOI16_icc) |
C++17 |
|
85 ms |
656 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 101;
int rang[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(vector<int> a, vector<int> b) {
if(a.size() == 1) {
return a[0];
}
int mid = a.size()/2;
auto lv = vector(a.begin(), a.begin()+mid), rv = vector(a.begin()+mid, a.end());
return qry(lv, b) ? find(lv, b) : find(rv, b);
}
void run(int n) {
iota(rang, rang+n+1, 0);
for(int i = 1; i <= n; ++i) ver[i].push_back(i);
for(int e = 0; e < n - 1; ++e) {
vector<int> root;
for(int i = 1; i <= n; ++i) if(rang[i] == i) root.push_back(i);
int roots = root.size();
int x = 0, k = -1;
for(int i = 0; (1 << i) < roots; ++i) {
vector<int> a, b;
for(int j = 0; j < roots; ++j) {
auto &v = (j >> i) & 1 ? a : b;
v.insert(v.end(), ver[root[j]].begin(), ver[root[j]].end());
}
if(qry(a, b)) {
x ^= (1 << i);
k = i;
}
}
int y = 0;
for(int i = 0; (1 << i) < roots; ++i) {
if(i == k) continue;
vector<int> a, b;
for(int j = 0; j < roots; ++j) {
auto &v = j & (1 << i | 1 << k) ? a : b;
v.insert(v.end(), ver[root[j]].begin(), ver[root[j]].end());
}
if(!qry(a, b)) y ^= (1 << i);
}
x ^= y;
int u = find(ver[root[x]], ver[root[y]]);
int v = find(ver[root[y]], ver[root[x]]);
setRoad(u, v);
for(auto& x : ver[rang[u]]) {
rang[x] = rang[v];
ver[rang[v]].push_back(x);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
600 KB |
Ok! 117 queries used. |
2 |
Correct |
4 ms |
616 KB |
Ok! 116 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
616 KB |
Ok! 650 queries used. |
2 |
Correct |
30 ms |
616 KB |
Ok! 600 queries used. |
3 |
Correct |
25 ms |
656 KB |
Ok! 656 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
616 KB |
Ok! 1607 queries used. |
2 |
Correct |
70 ms |
604 KB |
Ok! 1395 queries used. |
3 |
Correct |
74 ms |
600 KB |
Ok! 1613 queries used. |
4 |
Correct |
76 ms |
600 KB |
Ok! 1606 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
600 KB |
Ok! 1601 queries used. |
2 |
Correct |
81 ms |
604 KB |
Ok! 1599 queries used. |
3 |
Correct |
73 ms |
604 KB |
Ok! 1613 queries used. |
4 |
Correct |
77 ms |
640 KB |
Ok! 1606 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
604 KB |
Ok! 1581 queries used. |
2 |
Correct |
75 ms |
604 KB |
Ok! 1613 queries used. |
3 |
Correct |
83 ms |
644 KB |
Ok! 1549 queries used. |
4 |
Correct |
78 ms |
656 KB |
Ok! 1613 queries used. |
5 |
Correct |
75 ms |
604 KB |
Ok! 1606 queries used. |
6 |
Correct |
74 ms |
600 KB |
Ok! 1611 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
644 KB |
Ok! 1613 queries used. |
2 |
Correct |
83 ms |
600 KB |
Ok! 1613 queries used. |