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"
#define ll long long
#define vll vector<ll>
#define vllp vector<pair<ll, ll> >
#define vi vector <int>
#define vip vector <pair <int, int> >
#define db double
#define ld long double
#define pdb pair <double, double>
#define YES cout<<"YES"
#define NO cout<<"NO"
#define nl cout<<"\n"
#define vv vector <vector <ll> >
#define pll pair <ll, ll>
#define pi pair <int, int>
#define pb push_back
#define f first
#define s second
using namespace std;
const ll mod=1e9+7;
const ll modx=998244353;
const double eps=1e-9;
const ll INF=INT_MAX;
const ll INFINF=LLONG_MAX;
const int MAX_N=1000;
void Solve(int N)
{
vi ans, v;
for(int i = 1; i <= N; i++) v.pb(1);
for(int i = 1; i <= N; i++)
{
if(i==1) v[0]=0;
else v[i-1]=0, v[i-2]=1;
int report=Query(v);
if(report==1)
{
ans.pb(i);
break;
}
}
for(int i = 2; i <= N; i++)
{
vi cur=v;
int num=N-i+1;
// printf("%d\n", num);
// for(auto i: cur)
// {
// printf("%d ", i);
// }
// printf("\n");
// fflush(stdout);
while(num>1)
{
vi a, b;
int cnt=0;
for(auto j: cur)
{
if(cnt<num/2)
{
a.pb(j);
if(j==1) cnt++;
b.pb(0);
}
else
{
b.pb(j);
a.pb(0);
}
}
int report1=Query(a);
a[ans[i-2]-1]=1;
int report2=Query(a);
a[ans[i-2]-1]=0;
// printf("array a: ");
// for(auto i: a) printf("%d ", i);
// printf("\narray b: ");
// for(auto i: b) printf("%d ", i);
// printf("\n");
if(report1==report2) cur=a, num=cnt;
else cur=b, num-=cnt;
}
for(int i = 0; i < N; i++)
{
if(cur[i]==1) ans.pb(i+1), v[i]=0;
}
// printf("\n");
}
// printf("\n");
// for(auto i: ans)
// {
// printf("%d ", i);
// }
Answer(ans);
}
/*
5
4 2 5 3 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |