#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=105;
int A[N],B[N];
int Ask(vector<int> a, vector<int> b)
{
for(int i=0;i<a.size();i++) A[i]=a[i];
for(int i=0;i<b.size();i++) B[i]=b[i];
return query(a.size(),b.size(),A,B);
}
int p[N],n;
int Find(int x){ return p[x]==x?x:p[x]=Find(p[x]);}
void Union(int x, int y){ p[Find(x)]=Find(y);}
void init(){ for(int i=0;i<N;i++) p[i]=i;}
bool use[N];
vector<int> Extend(vector<int> a)
{
vector<int> _a;
for(int i=1;i<=n;i++) use[i]=0;
for(int i:a) use[i]=1;
for(int i=1;i<=n;i++) if(use[Find(i)]) _a.pb(i);
return _a;
}
int AskAll(vector<int> a, vector<int> b)
{
return Ask(Extend(a),Extend(b));
}
vector<int> Reduce1(vector<int> x, vector<int> y)
{
while(x.size()>1)
{
vector<int> v[2];
for(int i=0;i<x.size();i++) v[i&1].pb(x[i]);
if(AskAll(v[0],y)) x=v[0];
else x=v[1];
}
return x;
}
vector<int> Reduce2(vector<int> x, vector<int> y)
{
while(x.size()>1)
{
vector<int> v[2];
for(int i=0;i<x.size();i++) v[i&1].pb(x[i]);
if(Ask(v[0],y)) x=v[0];
else x=v[1];
}
return x;
}
void run(int _n)
{
n=_n;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
init();
for(int t=1;t<n;t++)
{
vector<int> root,v[2],u[2];
for(int i=1;i<=n;i++) if(Find(i)==i) root.pb(i);
while(1)
{
shuffle(root.begin(),root.end(),rng);
for(int i=0;i<root.size();i++) use[root[i]]=i&1;
v[0].clear();
v[1].clear();
for(int i=1;i<=n;i++) v[use[Find(i)]].pb(i);
if(Ask(v[0],v[1])) break;
}
for(int i=1;i<=n;i++) if(Find(i)==i) u[use[i]].pb(i);
u[0]=Reduce1(u[0],u[1]);
u[1]=Reduce1(u[1],u[0]);
v[0]=Extend(u[0]);
v[1]=Extend(u[1]);
v[0]=Reduce2(v[0],v[1]);
v[1]=Reduce2(v[1],v[0]);
setRoad(v[0][0],v[1][0]);
Union(v[0][0],v[1][0]);
}
}
Compilation message
icc.cpp: In function 'int Ask(std::vector<int>, std::vector<int>)':
icc.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<a.size();i++) A[i]=a[i];
~^~~~~~~~~
icc.cpp:10:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<b.size();i++) B[i]=b[i];
~^~~~~~~~~
icc.cpp: In function 'std::vector<int> Reduce1(std::vector<int>, std::vector<int>)':
icc.cpp:35:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<x.size();i++) v[i&1].pb(x[i]);
~^~~~~~~~~
icc.cpp: In function 'std::vector<int> Reduce2(std::vector<int>, std::vector<int>)':
icc.cpp:46:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<x.size();i++) v[i&1].pb(x[i]);
~^~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:64:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<root.size();i++) use[root[i]]=i&1;
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
504 KB |
Ok! 114 queries used. |
2 |
Correct |
10 ms |
504 KB |
Ok! 118 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
504 KB |
Ok! 649 queries used. |
2 |
Correct |
65 ms |
504 KB |
Ok! 813 queries used. |
3 |
Correct |
63 ms |
504 KB |
Ok! 804 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
504 KB |
Ok! 1854 queries used. |
2 |
Correct |
220 ms |
592 KB |
Ok! 2077 queries used. |
3 |
Correct |
203 ms |
504 KB |
Ok! 2060 queries used. |
4 |
Correct |
198 ms |
632 KB |
Ok! 2000 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
198 ms |
568 KB |
Too many queries! 2007 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
207 ms |
564 KB |
Too many queries! 2053 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
209 ms |
636 KB |
Too many queries! 2074 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |