#include<bits/stdc++.h>
using namespace std;
#include"library.h"
bitset<1005> vis;
vector<int> now,ans;
void Solve(int n){
int i,sz,x,y,head,l,r,mid,cnt;
now.resize(n);
for(i=0;i<n;i++)now[i]=1;
for(i=0;i<n;i++){
now[i]=0;
x=Query(now);
now[i]=1;
if(x==1){head=i;break;}
}
for(i=0;i<n;i++)now[i]=0;
vis[head]=true;
ans.push_back(head+1);
for(sz=n-1;sz>0;sz--){
l=1,r=sz;
while(l<r){
mid=(l+r)/2;
for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=1,cnt++;
x=Query(now);
now[head]=1;
y=Query(now);
now[head]=0;
for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=0,cnt++;
if(x==y)r=mid;
else l=mid+1;
}
for(i=0,cnt=0;i<n,cnt<l;i++)if(!vis[i])cnt++;
ans.push_back(i);
head=i-1;
vis[head]=true;
}
Answer(ans);
return ;
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:34:24: warning: left operand of comma operator has no effect [-Wunused-value]
34 | for(i=0,cnt=0;i<n,cnt<l;i++)if(!vis[i])cnt++;
| ~^~
library.cpp:20:23: warning: 'head' may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | ans.push_back(head+1);
| ~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
208 KB |
# of queries: 2387 |
2 |
Correct |
27 ms |
328 KB |
# of queries: 2433 |
3 |
Correct |
33 ms |
292 KB |
# of queries: 2638 |
4 |
Correct |
30 ms |
208 KB |
# of queries: 2593 |
5 |
Correct |
28 ms |
208 KB |
# of queries: 2504 |
6 |
Correct |
28 ms |
284 KB |
# of queries: 2553 |
7 |
Correct |
35 ms |
208 KB |
# of queries: 2568 |
8 |
Correct |
31 ms |
296 KB |
# of queries: 2402 |
9 |
Correct |
33 ms |
292 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
276 KB |
# of queries: 1478 |
11 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
208 KB |
# of queries: 2387 |
2 |
Correct |
27 ms |
328 KB |
# of queries: 2433 |
3 |
Correct |
33 ms |
292 KB |
# of queries: 2638 |
4 |
Correct |
30 ms |
208 KB |
# of queries: 2593 |
5 |
Correct |
28 ms |
208 KB |
# of queries: 2504 |
6 |
Correct |
28 ms |
284 KB |
# of queries: 2553 |
7 |
Correct |
35 ms |
208 KB |
# of queries: 2568 |
8 |
Correct |
31 ms |
296 KB |
# of queries: 2402 |
9 |
Correct |
33 ms |
292 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
276 KB |
# of queries: 1478 |
11 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |