# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
817081 |
2023-08-09T09:17:24 Z |
anton |
ICC (CEOI16_icc) |
C++17 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#include “icc.h”
using namespace std;
#define pii pair<int, int>
const int MAX_N = 1e2;
int n;
vector<int> groups[MAX_N];
int dsu[MAX_N];
int my_query(int sa, int sb, int a[], int b[]){
for(int i = 0; i<sa; i++){
//cout<<a[i]<<" ";
}
//cout<<endl<<"__"<<endl;
for(int i = 0; i<sb; i++){
//cout<<b[i]<<" ";
}
//cout<<endl;
/*int res;
cin>>res;*/
int res = query(sa, sb, a[], b[]);
return res;
}
void merge(int a, int b){
int ga = dsu[a];
int gb = dsu[b];
if(ga==gb){
return;
}
if(ga>gb){
swap(ga, gb);
}
for(auto e: groups[gb]){
groups[ga].push_back(e);
dsu[e] = ga;
}
groups[gb].clear();
}
void my_setRoad(int a, int b){
merge(a, b);
setRoad(a, b);
//cout<<"road "<<a<<" "<<b<<endl;
}
void pbv(vector<int>& a, vector<int>&b){
a.insert(a.end(), b.begin(), b.end());
}
vector<int> all_except(int id){
vector<int> b;
for(int i = 0; i<n; i++){
if(i!=id){
pbv(b, groups[i]);
}
}
return b;
}
int query_group(int id){
vector<int> a;
pbv(a, groups[id]);
vector<int> b = all_except(id);
return my_query(a.size(), b.size(),&a[0], &b[0]);
}
void find(vector<int>& a, vector<int>& b){
int aid = -1;
for(int step = (1<<7); step>=1; step/=2){
if(aid+step<a.size()){
if(aid+step==0){
aid+=step;
continue;
}
//cout<<"qa"<<endl;
if(my_query(a.size()-aid-step, b.size(), &a[aid+step], &b[0])){
aid+=step;
}
}
}
int bid= -1;
for(int step = (1<<7); step>=1; step/=2){
if(bid+step<b.size()){
if(bid+step==0){
bid+=step;
continue;
}
if(my_query(1, b.size()-bid-step, &a[aid], &b[bid+step])){
bid+=step;
}
}
}
//cout<<aid<<" "<<bid<<endl;
my_setRoad(a[aid], b[bid]);
}
pair<vector<int>, vector<int>> get_split(){
pair<vector<int>, vector<int>> pv;
for(int i = 0; i<n; i++){
if(rand()%2==0){
pbv(pv.first, groups[i]);
}
else{
pbv(pv.second, groups[i]);
}
}
if(pv.first.size()>0&& pv.second.size()>0){
return pv;
}
else{
return get_split();
}
}
void run(int N){
n = N;
srand(42);
for(int i = 0; i<n; i++){
dsu[i] = i;
groups[i].push_back(i);
}
for(int i = 0; i<n-1; i++){
/*for(int i = 0; i<n; i++){
if(groups[i].size()>0){
if(query_group(i)==1){
auto tmp = all_except(i);
find(groups[i], tmp);
}
}
}*/
auto pvv = get_split();
while(!my_query(pvv.first.size(), pvv.second.size(), &pvv.first[0], &pvv.second[0])){
pvv = get_split();
}
find(pvv.first, pvv.second);
}
}
Compilation message
icc.cpp:2:10: error: extended character “ is not valid in an identifier
2 | #include “icc.h”
| ^
icc.cpp:2:10: error: #include expects "FILENAME" or <FILENAME>
2 | #include “icc.h”
| ^~~~
icc.cpp:2:17: error: extended character ” is not valid in an identifier
2 | #include “icc.h”
| ^
icc.cpp: In function 'int my_query(int, int, int*, int*)':
icc.cpp:23:31: error: expected primary-expression before ']' token
23 | int res = query(sa, sb, a[], b[]);
| ^
icc.cpp:23:36: error: expected primary-expression before ']' token
23 | int res = query(sa, sb, a[], b[]);
| ^
icc.cpp:23:15: error: 'query' was not declared in this scope; did you mean 'my_query'?
23 | int res = query(sa, sb, a[], b[]);
| ^~~~~
| my_query
icc.cpp: In function 'void my_setRoad(int, int)':
icc.cpp:47:5: error: 'setRoad' was not declared in this scope; did you mean 'my_setRoad'?
47 | setRoad(a, b);
| ^~~~~~~
| my_setRoad
icc.cpp: In function 'void find(std::vector<int>&, std::vector<int>&)':
icc.cpp:78:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | if(aid+step<a.size()){
| ~~~~~~~~^~~~~~~~~
icc.cpp:92:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | if(bid+step<b.size()){
| ~~~~~~~~^~~~~~~~~