# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605636 |
2022-07-25T20:38:42 Z |
AlperenT |
ICC (CEOI16_icc) |
C++17 |
|
117 ms |
500 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Comp{
vector<int> nodes;
};
vector<vector<int>> tree;
vector<bool> vis;
void dfs(int v, vector<int> &vec){
vis[v] = true;
vec.push_back(v);
for(auto e : tree[v]){
if(!vis[e]) dfs(e, vec);
}
}
void run(int n){
tree.assign(n + 1, {});
int mx = 0;
for(int it = 0; it <= n - 1; it++){
int s, t;
vector<Comp> comps;
vis.assign(n + 1, false);
for(int v = 1; v <= n; v++){
if(!vis[v]){
Comp tmp;
comps.push_back(tmp);
dfs(v, comps.back().nodes);
}
}
vector<int> a, b, c;
for(int k = 0; k < 7; k++){
a.clear(), b.clear();
for(int i = 0; i < comps.size(); i++){
if(i & (1 << k)) for(auto v : comps[i].nodes) a.push_back(v);
else for(auto v : comps[i].nodes) b.push_back(v);
}
if(query(a.size(), b.size(), a.data(), b.data())) break;
}
shuffle(a.begin(), a.end(), rng);
shuffle(b.begin(), b.end(), rng);
int l = -1, r = a.size() - 1, m;
while(r - l > 1){
m = l + (r - l) / 2;
c.clear();
for(int i = 0; i <= m; i++) c.push_back(a[i]);
if(query(c.size(), b.size(), c.data(), b.data())) r = m;
else l = m;
}
s = a[r];
l = -1, r = b.size() - 1;
while(r - l > 1){
m = l + (r - l) / 2;
c.clear();
for(int i = 0; i <= m; i++) c.push_back(b[i]);
if(query(c.size(), a.size(), c.data(), a.data())) r = m;
else l = m;
}
t = b[r];
setRoad(s, t);
tree[s].push_back(t);
tree[t].push_back(s);
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Comp>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for(int i = 0; i < comps.size(); i++){
| ~~^~~~~~~~~~~~~~
icc.cpp:28:6: warning: unused variable 'mx' [-Wunused-variable]
28 | int mx = 0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
468 KB |
Ok! 105 queries used. |
2 |
Correct |
4 ms |
468 KB |
Ok! 104 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
468 KB |
Ok! 526 queries used. |
2 |
Correct |
33 ms |
468 KB |
Ok! 669 queries used. |
3 |
Correct |
32 ms |
468 KB |
Ok! 657 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
492 KB |
Ok! 1424 queries used. |
2 |
Correct |
115 ms |
500 KB |
Ok! 1613 queries used. |
3 |
Correct |
107 ms |
492 KB |
Ok! 1428 queries used. |
4 |
Correct |
105 ms |
496 KB |
Ok! 1527 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
468 KB |
Ok! 1501 queries used. |
2 |
Correct |
105 ms |
468 KB |
Ok! 1494 queries used. |
3 |
Correct |
111 ms |
492 KB |
Ok! 1605 queries used. |
4 |
Correct |
102 ms |
468 KB |
Ok! 1468 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
468 KB |
Ok! 1622 queries used. |
2 |
Correct |
112 ms |
496 KB |
Ok! 1621 queries used. |
3 |
Correct |
117 ms |
484 KB |
Ok! 1631 queries used. |
4 |
Correct |
109 ms |
500 KB |
Ok! 1606 queries used. |
5 |
Correct |
102 ms |
496 KB |
Ok! 1515 queries used. |
6 |
Correct |
117 ms |
468 KB |
Ok! 1565 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
492 KB |
Ok! 1601 queries used. |
2 |
Correct |
108 ms |
500 KB |
Ok! 1584 queries used. |