#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 solve(int ind,int l,int r){
//cout<<l<<" "<<r<<endl;
if(l==r){
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){
return l;
}
else{
return -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 and i!=ind){
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){
return solve(ind,l,mid);
}
else{
return 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;
for(int i=0;i<n;i++){
int y=x;
if(i==n-1 and st==0){
break;
}
x=solve(x,0,n-1);
if(x==-1){
x=0;
st=1;
kk+=1;
}
else{
if(st==0){
ans.push_back(x);
}
else{
ans.push_front(x);
}
}
aa[y]=0;
}
if(kk>1){
while(true){
continue;
}
}
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(4);
return 0;
}*/
Compilation message
library.cpp: In function 'int solve(int, int, int)':
library.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
384 KB |
# of queries: 2940 |
2 |
Correct |
50 ms |
256 KB |
# of queries: 2901 |
3 |
Correct |
53 ms |
256 KB |
# of queries: 3084 |
4 |
Correct |
53 ms |
256 KB |
# of queries: 3038 |
5 |
Correct |
52 ms |
384 KB |
# of queries: 3062 |
6 |
Correct |
49 ms |
256 KB |
# of queries: 3074 |
7 |
Correct |
50 ms |
256 KB |
# of queries: 3026 |
8 |
Correct |
48 ms |
256 KB |
# of queries: 2937 |
9 |
Correct |
51 ms |
432 KB |
# of queries: 3079 |
10 |
Execution timed out |
3063 ms |
384 KB |
Time limit exceeded |
11 |
Correct |
4 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 5 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 9 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 104 |
16 |
Correct |
9 ms |
256 KB |
# of queries: 253 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
384 KB |
# of queries: 2940 |
2 |
Correct |
50 ms |
256 KB |
# of queries: 2901 |
3 |
Correct |
53 ms |
256 KB |
# of queries: 3084 |
4 |
Correct |
53 ms |
256 KB |
# of queries: 3038 |
5 |
Correct |
52 ms |
384 KB |
# of queries: 3062 |
6 |
Correct |
49 ms |
256 KB |
# of queries: 3074 |
7 |
Correct |
50 ms |
256 KB |
# of queries: 3026 |
8 |
Correct |
48 ms |
256 KB |
# of queries: 2937 |
9 |
Correct |
51 ms |
432 KB |
# of queries: 3079 |
10 |
Execution timed out |
3063 ms |
384 KB |
Time limit exceeded |
11 |
Correct |
4 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 5 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 9 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 104 |
16 |
Correct |
9 ms |
256 KB |
# of queries: 253 |
17 |
Execution timed out |
3010 ms |
256 KB |
Time limit exceeded |
18 |
Correct |
468 ms |
384 KB |
# of queries: 19485 |
19 |
Correct |
493 ms |
504 KB |
# of queries: 19764 |
20 |
Correct |
447 ms |
380 KB |
# of queries: 18574 |
21 |
Execution timed out |
3092 ms |
384 KB |
Time limit exceeded |
22 |
Execution timed out |
3014 ms |
384 KB |
Time limit exceeded |
23 |
Correct |
480 ms |
376 KB |
# of queries: 19749 |
24 |
Execution timed out |
3082 ms |
384 KB |
Time limit exceeded |
25 |
Execution timed out |
3035 ms |
384 KB |
Time limit exceeded |
26 |
Execution timed out |
3060 ms |
256 KB |
Time limit exceeded |
27 |
Correct |
175 ms |
376 KB |
# of queries: 9065 |
28 |
Correct |
269 ms |
504 KB |
# of queries: 11067 |
29 |
Correct |
279 ms |
376 KB |
# of queries: 11060 |
30 |
Correct |
279 ms |
408 KB |
# of queries: 11067 |