#include <iostream>
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
#define pb push_back
typedef long long llo;
#define a first
#define b second
int n;
vector<int> aa;
vector<int> bb;
/*
void Answer(vector<int> cc){
for(auto j:cc)
{ cout<<j<<" ";
}
cout<<endl;
}
int Query(vector<int> cc){
for(auto j:cc){
cout<<j<<" ";
}
cout<<endl;
int xx;
cin>>xx;
return xx;
}*/
int ll;
void solve(int ind,int l,int r){
//cout<<l<<" "<<r<<endl;
if(l==r){
if(aa[l]==0){
ll=-1;
return ;
}
/* if(ind==l){
ll=-1;
while(true){
continue;
}
}
else{*/
for(int i=0;i<n;i++){
if((ind==i or i==l)){
bb[i]=1;
}
else{
bb[i]=0;
}
}
int yy=Query(bb);
if(yy==1){
aa[l]=0;
ll=l;
}
else{
ll=-1;
}
//}
}
else{
int mid=(l+r)/2;
int co=0;
for(int i=0;i<n;i++){
bb[i]=0;
}
for(int i=l;i<=mid;i++){
if(aa[i]==2){
bb[i]=1;
co+=1;
}
}
if(co==0){
solve(ind,mid+1,r);
}
else{
bb[ind]=1;
int yy=Query(bb);
bb[ind]=0;
int zz=Query(bb);
if(yy==zz){
solve(ind,l,mid);
}
else{
solve(ind,mid+1,r);
}
}
}
}
void Solve(int nn){
n=nn;
for(int i=0;i<n;i++){
aa.pb(2);
bb.pb(0);
}
int x=0;
deque<int> ans;
ans.push_back(0);
int st=0;
int kk=0;
int le=n-1;
aa[0]=0;
int cco=0;
while(le){
cco+=1;
int y=x;
ll=-2;
solve(x,0,n-1);
if(ll!=-1){
le-=1;
if(aa[ll]==0){
while(true){
continue;
}
}
}
x=ll;
if(x==-1){
x=0;
st=1;
kk+=1;
}
else{
if(st==0){
ans.push_back(x);
}
else{
ans.push_front(x);
}
}
aa[x]=0;
aa[y]=0;
}
vector<int> fin;
for(int i=0;i<n;i++){
int x=ans.front();
ans.pop_front();
fin.pb(x+1);
}
Answer(fin);
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Solve(5);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
2 |
Execution timed out |
3077 ms |
384 KB |
Time limit exceeded |
3 |
Execution timed out |
3057 ms |
384 KB |
Time limit exceeded |
4 |
Execution timed out |
3095 ms |
256 KB |
Time limit exceeded |
5 |
Execution timed out |
3082 ms |
256 KB |
Time limit exceeded |
6 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
7 |
Execution timed out |
3098 ms |
256 KB |
Time limit exceeded |
8 |
Execution timed out |
3074 ms |
256 KB |
Time limit exceeded |
9 |
Execution timed out |
3076 ms |
384 KB |
Time limit exceeded |
10 |
Execution timed out |
3070 ms |
256 KB |
Time limit exceeded |
11 |
Correct |
5 ms |
384 KB |
# of queries: 0 |
12 |
Execution timed out |
3091 ms |
256 KB |
Time limit exceeded |
13 |
Execution timed out |
3057 ms |
384 KB |
Time limit exceeded |
14 |
Execution timed out |
3085 ms |
256 KB |
Time limit exceeded |
15 |
Execution timed out |
3093 ms |
432 KB |
Time limit exceeded |
16 |
Execution timed out |
3072 ms |
384 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
2 |
Execution timed out |
3077 ms |
384 KB |
Time limit exceeded |
3 |
Execution timed out |
3057 ms |
384 KB |
Time limit exceeded |
4 |
Execution timed out |
3095 ms |
256 KB |
Time limit exceeded |
5 |
Execution timed out |
3082 ms |
256 KB |
Time limit exceeded |
6 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
7 |
Execution timed out |
3098 ms |
256 KB |
Time limit exceeded |
8 |
Execution timed out |
3074 ms |
256 KB |
Time limit exceeded |
9 |
Execution timed out |
3076 ms |
384 KB |
Time limit exceeded |
10 |
Execution timed out |
3070 ms |
256 KB |
Time limit exceeded |
11 |
Correct |
5 ms |
384 KB |
# of queries: 0 |
12 |
Execution timed out |
3091 ms |
256 KB |
Time limit exceeded |
13 |
Execution timed out |
3057 ms |
384 KB |
Time limit exceeded |
14 |
Execution timed out |
3085 ms |
256 KB |
Time limit exceeded |
15 |
Execution timed out |
3093 ms |
432 KB |
Time limit exceeded |
16 |
Execution timed out |
3072 ms |
384 KB |
Time limit exceeded |
17 |
Execution timed out |
3017 ms |
384 KB |
Time limit exceeded |
18 |
Execution timed out |
3065 ms |
384 KB |
Time limit exceeded |
19 |
Execution timed out |
3073 ms |
384 KB |
Time limit exceeded |
20 |
Execution timed out |
3087 ms |
384 KB |
Time limit exceeded |
21 |
Execution timed out |
3084 ms |
256 KB |
Time limit exceeded |
22 |
Execution timed out |
3091 ms |
256 KB |
Time limit exceeded |
23 |
Execution timed out |
3072 ms |
384 KB |
Time limit exceeded |
24 |
Execution timed out |
3039 ms |
256 KB |
Time limit exceeded |
25 |
Execution timed out |
3098 ms |
384 KB |
Time limit exceeded |
26 |
Execution timed out |
3022 ms |
384 KB |
Time limit exceeded |
27 |
Execution timed out |
3089 ms |
256 KB |
Time limit exceeded |
28 |
Execution timed out |
3084 ms |
384 KB |
Time limit exceeded |
29 |
Execution timed out |
3090 ms |
256 KB |
Time limit exceeded |
30 |
Execution timed out |
3073 ms |
384 KB |
Time limit exceeded |