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 <cstdio>
#include <vector>
#include <iostream>
#include "library.h"
using namespace std;
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mk make_pair
typedef long long ll;
const int N=1e3+7;
int vis[N];
vector<int>vec,a,b;
void Solve(int n){
vector<int> m;
vector<int> ans;
int x=1;
for(int i=1;i<=n;i++){
m.clear();
for(int j=1;j<=n;j++){
int g=1;
if(j==i)g=0;
m.pb(g);
}
int y=Query(m);
if(y==1){
x=i;
break;
}
}
fill(vis,vis+N,0);
ans.pb(x);vis[x]=1;
for(int i=2;i<=n;i++){
a.clear();
for(int j=1;j<=n;j++){
if(!vis[j])a.pb(j);
}
while(a.size()>1){
b.clear();
while(a.size()>b.size()){
b.pb(a.back());
a.pop_back();
}
m.clear();
for(int j=1;j<=n;j++){
int g=1;if(vis[j])g=0;
m.pb(g);
}
for(auto j:b)m[j-1]=0;
int val=Query(m);
for(int j=1;j<=n;j++){
if(vis[j])m[j-1]=1;
}
int val2=Query(m);
if(val!=val2){
swap(a,b);
}
}
ans.pb(a[0]);
vis[a[0]]=1;
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |