#include "chameleon.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector<int> vec;
int cnt = 0;
int askrange(vector<int> cur, int i, int j){
vector<int> temp;
for(int u: cur)
temp.push_back(u);
for(int k=i; k<=j; k++)
temp.push_back(vec[k]);
cnt++;
assert(cnt <= 20000);
return Query(temp);
}
void Solve(int N) {
int i;
for(i=1; i<=2*N; i++)
vec.push_back(i);
for(i=1; i<=N; i++){
int lo = 0, hi = (int)vec.size() - 1, mid;
while(1){
mid = (lo+hi) / 2;
if(askrange({}, lo, mid) < mid-lo+1)
hi = mid;
else if(askrange({}, mid+1, hi) < hi-mid)
lo = mid+1;
else
break;
}
int crit = lo;
lo = mid+1;
while(lo < hi){
mid = (lo+hi)/2;
if(askrange({vec[crit]}, lo, mid) == mid-lo+2)
lo = mid+1;
else
hi = mid;
}
//printf("crit=%d lo=%d\n", crit, lo);
Answer(vec[crit], vec[lo]);
vec.erase(find(vec.begin(), vec.end(), vec[lo]));
vec.erase(find(vec.begin(), vec.end(), vec[crit]));
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
4 |
Halted |
0 ms |
0 KB |
- |