# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
223526 |
2020-04-15T10:46:01 Z |
MKopchev |
ICC (CEOI16_icc) |
C++14 |
|
156 ms |
636 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int nmax=100+42;
/*
void setRoad(int a,int b)
{
cout<<"set "<<a<<" "<<b<<endl;
}
int query(int size_a,int size_b,int a[],int b[])
{
cout<<"size_a "<<size_a<<" a ";for(int i=0;i<size_a;i++)cout<<a[i]<<" ";cout<<endl;
cout<<"size_b "<<size_b<<" b ";for(int i=0;i<size_b;i++)cout<<b[i]<<" ";cout<<endl;
int ret;
cin>>ret;
return ret;
}
*/
int size_a,size_b,a[nmax],b[nmax];
int n;
int parent[nmax];
int root(int node)
{
if(node==parent[node])return parent[node];
parent[node]=root(parent[node]);
return parent[node];
}
int my_ask(vector<int> lhs,vector<int> rhs)
{
size_a=lhs.size();
for(int i=0;i<size_a;i++)
a[i]=lhs[i];
size_b=rhs.size();
for(int i=0;i<size_b;i++)
b[i]=rhs[i];
return query(size_a,size_b,a,b);
}
vector<int> in[nmax];
mt19937 rng(1337);
void my_merge(int u,int v)
{
setRoad(u,v);
int le=root(u),ri=root(v);
for(auto k:in[ri])
in[le].push_back(k);
in[ri]={};
parent[ri]=le;
}
void my_reduce(vector<int> &to_reduce,vector<int> other)
{
while(to_reduce.size()>1)
{
vector<int> help[2];
help[0]={};
help[1]={};
for(int i=0;i<to_reduce.size();i++)
help[i%2].push_back(to_reduce[i]);
if(my_ask(help[0],other))to_reduce=help[0];
else to_reduce=help[1];
}
}
void run(int N)
{
n=N;
for(int i=1;i<=n;i++)parent[i]=i,in[i]={i};
for(int road=1;road<n;road++)
{
vector<int> lhs={};
vector<int> rhs={};
for(int bit=10;bit>=0;bit--)
{
lhs={};
rhs={};
for(int i=1;i<=n;i++)
if((i&(1<<bit)))
{
for(auto w:in[i])lhs.push_back(w);
}
else
{
for(auto w:in[i])rhs.push_back(w);
}
if(lhs.size()==0||rhs.size()==0)continue;
if(my_ask(lhs,rhs))break;
}
my_reduce(lhs,rhs);
my_reduce(rhs,lhs);
int u=lhs[0],v=rhs[0];
my_merge(u,v);
}
}
/*
int main()
{
run(4);
}
*/
Compilation message
icc.cpp: In function 'void my_reduce(std::vector<int>&, std::vector<int>)':
icc.cpp:76:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<to_reduce.size();i++)
~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
512 KB |
Ok! 99 queries used. |
2 |
Correct |
11 ms |
512 KB |
Ok! 106 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
512 KB |
Ok! 546 queries used. |
2 |
Correct |
49 ms |
512 KB |
Ok! 666 queries used. |
3 |
Correct |
50 ms |
512 KB |
Ok! 661 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
135 ms |
632 KB |
Ok! 1398 queries used. |
2 |
Correct |
156 ms |
512 KB |
Ok! 1651 queries used. |
3 |
Correct |
128 ms |
632 KB |
Ok! 1408 queries used. |
4 |
Correct |
139 ms |
512 KB |
Ok! 1528 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
604 KB |
Ok! 1380 queries used. |
2 |
Correct |
130 ms |
512 KB |
Ok! 1418 queries used. |
3 |
Correct |
152 ms |
572 KB |
Ok! 1619 queries used. |
4 |
Correct |
126 ms |
512 KB |
Ok! 1378 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
512 KB |
Ok! 1629 queries used. |
2 |
Correct |
149 ms |
512 KB |
Ok! 1638 queries used. |
3 |
Correct |
149 ms |
636 KB |
Ok! 1642 queries used. |
4 |
Correct |
153 ms |
632 KB |
Ok! 1600 queries used. |
5 |
Correct |
133 ms |
512 KB |
Ok! 1442 queries used. |
6 |
Correct |
145 ms |
512 KB |
Ok! 1564 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
155 ms |
512 KB |
Too many queries! 1631 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |