# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1092826 |
2024-09-25T08:16:42 Z |
Fran |
ICC (CEOI16_icc) |
C++17 |
|
94 ms |
652 KB |
#include "icc.h"
#include<bits/stdc++.h>
using namespace std;
constexpr int N = 101;
int rang[101];
vector<int> ver[101];
int qry(vector<int> a, vector<int> b) {
return query(a.size(), b.size(), &a[0], &b[0]);
}
int find(int x) {
return rang[x] == x ? x : rang[x] = find(rang[x]);
}
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[v]]) {
rang[x] = rang[u];
ver[rang[u]].push_back(x);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
600 KB |
Ok! 117 queries used. |
2 |
Correct |
5 ms |
600 KB |
Ok! 116 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
604 KB |
Ok! 650 queries used. |
2 |
Correct |
27 ms |
636 KB |
Ok! 551 queries used. |
3 |
Correct |
26 ms |
632 KB |
Ok! 591 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
604 KB |
Ok! 1573 queries used. |
2 |
Correct |
79 ms |
604 KB |
Ok! 1372 queries used. |
3 |
Correct |
90 ms |
640 KB |
Ok! 1613 queries used. |
4 |
Correct |
85 ms |
644 KB |
Ok! 1497 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
640 KB |
Ok! 1564 queries used. |
2 |
Correct |
88 ms |
648 KB |
Ok! 1543 queries used. |
3 |
Correct |
83 ms |
652 KB |
Ok! 1488 queries used. |
4 |
Correct |
89 ms |
600 KB |
Ok! 1608 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
636 KB |
Ok! 1414 queries used. |
2 |
Correct |
85 ms |
640 KB |
Ok! 1433 queries used. |
3 |
Correct |
83 ms |
600 KB |
Ok! 1424 queries used. |
4 |
Correct |
81 ms |
636 KB |
Ok! 1452 queries used. |
5 |
Correct |
92 ms |
600 KB |
Ok! 1587 queries used. |
6 |
Correct |
90 ms |
644 KB |
Ok! 1575 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
640 KB |
Ok! 1448 queries used. |
2 |
Correct |
80 ms |
600 KB |
Ok! 1420 queries used. |