# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
817086 |
2023-08-09T09:19:33 Z |
anton |
ICC (CEOI16_icc) |
C++17 |
|
121 ms |
512 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+1];
int dsu[MAX_N+1];
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+1] = i;
groups[i].push_back(i+1);
}
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 |
Correct |
4 ms |
468 KB |
Ok! 106 queries used. |
2 |
Correct |
4 ms |
468 KB |
Ok! 109 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
504 KB |
Ok! 549 queries used. |
2 |
Correct |
36 ms |
484 KB |
Ok! 865 queries used. |
3 |
Correct |
34 ms |
508 KB |
Ok! 821 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
512 KB |
Ok! 1545 queries used. |
2 |
Correct |
121 ms |
512 KB |
Ok! 2180 queries used. |
3 |
Correct |
93 ms |
512 KB |
Ok! 1785 queries used. |
4 |
Correct |
94 ms |
512 KB |
Ok! 1792 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
508 KB |
Ok! 1733 queries used. |
2 |
Correct |
94 ms |
504 KB |
Ok! 1797 queries used. |
3 |
Correct |
102 ms |
508 KB |
Ok! 1826 queries used. |
4 |
Correct |
92 ms |
512 KB |
Ok! 1735 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
500 KB |
Too many queries! 1869 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
504 KB |
Too many queries! 1895 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |