#include<bits/stdc++.h>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
int n;
int ask(vector<int> v){
vector<int> r(n);
fill(r.begin(),r.end(),0);
for(int i:v)
r[i] = 1;
return Query(v);
}
void Solve(int N)
{
n=N;
vector<int> M(N);
for(int i = 0; i < N; i++) {
M[i] = 1;
}
int border = -1;
for(int i = 0; i < n ; i++){
M[i] = 0;
int r = Query(M);
if(r==1){
//border
border = i;
break;
}
M[i] = 1;
}
bool in[n];
fill(in,in+n,false);
in[border] = true;
vector<vector<int>> chaines;
int tot = 1;
while(tot<N){
vector<int> chaine;
vector<int> q(n);
fill(q.begin(),q.end(),0);
for(int i = 0;i<n;i++){
if(!in[i]){
q[i] = 1;
if(Query(q)==1){
chaine.push_back(i);
tot++;
in[i] = true;
}else{
q[i] = 0;
}
}
}
chaines.push_back(chaine);
}
if(chaines.size()>6){
while(true);
}
vector<int> ans;
ans.push_back(border);
vector<int> asking(n);
fill(asking.begin(),asking.end(),0);
asking[border] = 1;
for(int i = 1; i < n ; i ++){
for(int c = 0; c < (int)chaines.size(); c++){
int low = 0;
int high = chaines[c].size();
while(low<high){
int mid = (low+high)/2;
for(int i = low ; i <= mid ; i++)
asking[chaines[c][i]] = 1;
int Q = Query(asking);
for(int i = low ; i <= mid ; i++)
asking[chaines[c][i]] = 0;
if(Q==1){
high = mid;
}else{
low = mid + 1;
}
}
if(low != (int)(chaines[c].size())){
//finded !
int nxt = chaines[c][low];
chaines[c].erase(chaines[c].begin()+low);
ans.push_back(nxt);
asking[nxt] = 1;
break;
}
}
}
for(int i = 0;i<n;i++)ans[i]++;
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3086 ms |
416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3086 ms |
416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |