# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
817084 |
2023-08-09T09:18:24 Z |
anton |
ICC (CEOI16_icc) |
C++17 |
|
1 ms |
432 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: 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()){
| ~~~~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Query cities not in range [1, n] |
2 |
Halted |
0 ms |
0 KB |
- |