This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void bewdva(vector <int> q){
for(int h=0; h<q.size(); h++) cout<<q[h]<<" ";
cout<<endl;
//exit(0);
}
int a,b,c,d,e,i,j,ii,jj,zx,xc,p[1009],fx[1009];
void rec(vector <int> q){
//cout<<p[i]<<" ";
//bewdva(q);
if(q.size()==1){
p[i+1]=q[0];
return;
}
vector <int> w;
while(w.size()<q.size()){
w.push_back(q[q.size()-1]);
q.pop_back();
}
vector <int> v;
for(j=1; j<=a; j++) v.push_back(0);
v[p[i]-1]=1;
for(j=0; j<q.size(); j++){
v[q[j]-1]=1;
}
//bewdva(v);
int qw=Query(v);
v[p[i]-1]=0;
//bewdva(v);
int we=Query(v);
if(qw==we){
rec(q);
}else{
rec(w);
}
}
void Solve(int N){
a=N;
vector <int> v,vv;
if(a<=2){
for(i=1; i<=a; i++) vv.push_back(i);
Answer(vv);
}else{
for(i=1; i<=a; i++) v.push_back(1);
for(i=1; i<=a; i++){
v[i-1]=0;
c=Query(v);
if(c==1){
if(zx==0){
zx=i;
}else{
xc=i;
}
}
v[i-1]=1;
}
p[1]=zx;p[a]=xc;
fx[zx]=1;fx[xc]=1;
for(i=1; i<a-1; i++){
v.clear();
for(j=1; j<=a; j++) if(fx[j]==0) v.push_back(j);
rec(v);
fx[p[i+1]]=1;
}
/*cout<<"#23";
exit(0);*/
for(i=1; i<=a; i++){
if(fx[i]==0){
p[a-1]=i;
break;
}
}
v.clear();
for(i=1; i<=a; i++) v.push_back(p[i]);
//bewdva(v);
Answer(v);
}
}
Compilation message (stderr)
library.cpp: In function 'void bewdva(std::vector<int>)':
library.cpp:5:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | for(int h=0; h<q.size(); h++) cout<<q[h]<<" ";
| ~^~~~~~~~~
library.cpp: In function 'void rec(std::vector<int>)':
library.cpp:25:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(j=0; j<q.size(); j++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |