#include "library.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n;
int vis[maxn];
vector<int> vec, ans;
int link(int st) {
vector<int> a;
vis[st] = 1;
for(int i=1;i<=n;i++) if(!vis[i]) a.push_back(i);
int l = 0, r = a.size()-1;
while(l<r) {
//ask
int mid = (l+r)/2;
for(int i=l;i<=r;i++) if(i<=mid) vec[a[i]-1] = 1;
int bef = Query(vec);
vec[st-1] = 1;
int aft = Query(vec);
//reset
for(int i=l;i<=r;i++) if(i<=mid) vec[a[i]-1] = 0;
vec[st-1] = 0;
//divide
if(bef==aft) r = mid;
else l = mid+1;
}
return a[l];
}
void Solve(int N) {
n = N;
if(n==1) return Answer({1});
//1000
int st = -1;
for(int i=0;i<n;i++) vec.push_back(0);
for(int x=1;x<=n;x++) {
for(int i=1;i<=n;i++) vec[x-1] = (x!=i);
if(Query(vec)==1) st = x;
}
ans.push_back(st);
//1000 * 10
for(int i=0;i<n;i++) vec[i] = 0;
for(int i=1;i<n;i++) ans.push_back(link(ans[i-1]));
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
248 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
248 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |