# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
713914 |
2023-03-23T08:23:18 Z |
vjudge1 |
ICC (CEOI16_icc) |
C++17 |
|
137 ms |
628 KB |
#include <bits/stdc++.h>
#include "icc.h"
#define MAX 105
typedef std::pair<int,int> pii;
int query(int size_a, int size_b, int a[], int b[]);
int query(std::vector<int> a,std::vector<int> b){
for(auto&x:a)++x;
for(auto&x:b)++x;
return query(a.size(),b.size(),a.data(),b.data());
}
void setRoad(int a, int b);
void InformaRua(int a,int b){setRoad(a+1,b+1);}
int pai[MAX];
int find(int a){
if(pai[a]==a){
return a;
}
return pai[a]=find(pai[a]);
}
void Union(int a,int b){
a=find(a);
b=find(b);
pai[a]=b;
}
std::vector<std::vector<int>> gerar_grupos(int N){
std::map<int,std::vector<int>> mapa;
for(int i=0;i!=N;++i){
mapa[find(i)].push_back(i);
}
std::vector<std::vector<int>> res;
for(auto&x:mapa){
res.push_back(x.second);
}
return res;
}
int splits[20];
int lvl;
int andar[MAX];
void dnc(int l,int r,int nv){
if(l==r)return;
lvl=std::max(lvl,nv);
int m = (l+r)/2;
for(int i=l;i<=m;++i)andar[i]+=(1<<nv);
dnc(l,m,nv+1);
dnc(m+1,r,nv+1);
}
void add(std::vector<int>& ref,std::vector<int> cp){
for(auto&x:cp)ref.push_back(x);
}
void pruning(std::vector<int>& a,std::vector<int> b){
while(a.size()!=1){
int m = a.size()/2;
std::vector<int> c,d;
for(int i=0;i<m;++i){
c.push_back(a[i]);
}
for(int i=m;i!=a.size();++i){
d.push_back(a[i]);
}
if(query(c,b)){
a=c;
}else a=d;
}
}
void run(int N) {
for(int i=0;i!=MAX;++i)pai[i]=i;
for(int i=1;i!=N;++i){
auto grups = gerar_grupos(N);
memset(andar,0,sizeof(andar));
lvl=0;
dnc(0,grups.size()-1,0);
std::random_shuffle(grups.begin(),grups.end());
std::vector<int> l,r;
for(int j=0;j!=20;++j){
std::vector<int> a,b;
for(int k=0;k!=grups.size();++k){
if(!(andar[k]&(1<<j))){
add(a,grups[k]);
}else add(b,grups[k]);
}
if(j==lvl||query(a,b)){
l=a;
r=b;
goto prox;
}
}
prox:
pruning(l,r);
pruning(r,l);
InformaRua(l[0],r[0]);
Union(l[0],r[0]);
}
}
Compilation message
icc.cpp: In function 'void pruning(std::vector<int>&, std::vector<int>)':
icc.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=m;i!=a.size();++i){
| ~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:89:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | for(int k=0;k!=grups.size();++k){
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
468 KB |
Ok! 99 queries used. |
2 |
Correct |
7 ms |
428 KB |
Ok! 100 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
468 KB |
Ok! 526 queries used. |
2 |
Correct |
33 ms |
468 KB |
Ok! 635 queries used. |
3 |
Correct |
34 ms |
468 KB |
Ok! 642 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
468 KB |
Ok! 1458 queries used. |
2 |
Correct |
120 ms |
468 KB |
Ok! 1587 queries used. |
3 |
Correct |
116 ms |
520 KB |
Ok! 1564 queries used. |
4 |
Correct |
112 ms |
468 KB |
Ok! 1526 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
504 KB |
Ok! 1494 queries used. |
2 |
Correct |
108 ms |
524 KB |
Ok! 1482 queries used. |
3 |
Correct |
135 ms |
504 KB |
Ok! 1571 queries used. |
4 |
Correct |
97 ms |
520 KB |
Ok! 1415 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
468 KB |
Ok! 1578 queries used. |
2 |
Correct |
119 ms |
468 KB |
Ok! 1612 queries used. |
3 |
Correct |
137 ms |
468 KB |
Ok! 1606 queries used. |
4 |
Correct |
137 ms |
628 KB |
Ok! 1591 queries used. |
5 |
Correct |
110 ms |
424 KB |
Ok! 1525 queries used. |
6 |
Correct |
116 ms |
500 KB |
Ok! 1607 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
512 KB |
Ok! 1584 queries used. |
2 |
Correct |
111 ms |
468 KB |
Ok! 1570 queries used. |