#include<bits/stdc++.h>
#include "library.h"
using namespace std;
const int maxn=1000+10;
int vis[maxn],n;
vector<int>ers;
int findsar(){
for(int i=0;i<n;i++){
ers.clear();
ers.resize(n,1);
ers[i]=0;
int r=Query(ers);
if(r==1){
return i;
}
}
return 0;
}
int findbad(vector<int>r,vector<int>s){
// cout<<"wtf: "<<(int)r.size()<<" "<<s.size()<<endl;
if((int)s.size()==1){
return s[0];
}
int m=(int)s.size();
m>>=1;
ers.clear();
ers.resize(n);
for(auto x:r){
ers[x]=1;
}
for(int i=0;i<m;i++){
ers[s[i]]=1;
}
int resr=Query(ers);
ers.clear();
ers.resize(n);
for(int i=0;i<m;i++){
ers[s[i]]=1;
}
int resrr=Query(ers);
if(resrr==resr){
vector<int>fake;
for(int i=0;i<m;i++){
fake.push_back(s[i]);
}
return findbad(r,fake);
}
vector<int>fake;
for(int i=m;i<(int)s.size();i++){
fake.push_back(s[i]);
}
return findbad(r,fake);
}
void Solve(int N)
{
n=N;
int av=findsar();
vector<int>res={av};
vis[av]=1;
//cout<<av<<endl;
for(int i=0;i<N-1;i++){
vector<int>all;
for(int j=0;j<n;j++){
if(vis[j]==0){
all.push_back(j);
}
}
res.push_back(findbad(res,all));
vis[res.back()]=1;
}
for(int i=0;i<n;i++){
res[i]++;
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
948 KB |
# of queries: 2375 |
2 |
Correct |
18 ms |
1200 KB |
# of queries: 2409 |
3 |
Correct |
20 ms |
1464 KB |
# of queries: 2648 |
4 |
Correct |
19 ms |
1524 KB |
# of queries: 2595 |
5 |
Correct |
19 ms |
1496 KB |
# of queries: 2508 |
6 |
Correct |
18 ms |
1504 KB |
# of queries: 2551 |
7 |
Correct |
23 ms |
1208 KB |
# of queries: 2544 |
8 |
Correct |
20 ms |
1456 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
1464 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
1212 KB |
# of queries: 1474 |
11 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
948 KB |
# of queries: 2375 |
2 |
Correct |
18 ms |
1200 KB |
# of queries: 2409 |
3 |
Correct |
20 ms |
1464 KB |
# of queries: 2648 |
4 |
Correct |
19 ms |
1524 KB |
# of queries: 2595 |
5 |
Correct |
19 ms |
1496 KB |
# of queries: 2508 |
6 |
Correct |
18 ms |
1504 KB |
# of queries: 2551 |
7 |
Correct |
23 ms |
1208 KB |
# of queries: 2544 |
8 |
Correct |
20 ms |
1456 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
1464 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
1212 KB |
# of queries: 1474 |
11 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |