#include <cstdio>
#include <vector>
#include "library.h"
#define pb push_back
#define ll int
using namespace std;
ll n;
vector<ll> v,v1,ans;
bool ok(ll mid, ll idx){
for(int i = 0; i < n; i++) v[i] = 0;
for(int i = 0; i <= mid; i++) v[v1[i] - 1] = 1;
ll x = Query(v);
v[ans[idx] - 1] = 1;
x -= Query(v);
return (!x);
}
void Solve(int N){
n = N;
v.assign(n, 0LL);
ans.assign(n, 0LL);
for(int i = 1; i <= n; i++) v1.pb(i);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
v[j] = (j != i);
}
ll x = Query(v);
if(x == 1){
ans[0] = i + 1;
v1.erase(v1.begin() + i);
break;
}
}
for(int i = 1; i < n; i++){
ll l = -1, r = v1.size();
while(r > l + 1){
ll mid = l + (r - l) / 2;
if(ok(mid, i - 1)) r = mid;
else l = mid;
}
ans[i] = v1[r];
v1.erase(v1.begin() + r);
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
344 KB |
# of queries: 2401 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2437 |
3 |
Correct |
23 ms |
344 KB |
# of queries: 2658 |
4 |
Correct |
30 ms |
344 KB |
# of queries: 2597 |
5 |
Correct |
19 ms |
344 KB |
# of queries: 2526 |
6 |
Correct |
19 ms |
344 KB |
# of queries: 2565 |
7 |
Correct |
21 ms |
344 KB |
# of queries: 2556 |
8 |
Correct |
20 ms |
344 KB |
# of queries: 2424 |
9 |
Correct |
24 ms |
344 KB |
# of queries: 2550 |
10 |
Correct |
16 ms |
344 KB |
# of queries: 1488 |
11 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
344 KB |
# of queries: 2401 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2437 |
3 |
Correct |
23 ms |
344 KB |
# of queries: 2658 |
4 |
Correct |
30 ms |
344 KB |
# of queries: 2597 |
5 |
Correct |
19 ms |
344 KB |
# of queries: 2526 |
6 |
Correct |
19 ms |
344 KB |
# of queries: 2565 |
7 |
Correct |
21 ms |
344 KB |
# of queries: 2556 |
8 |
Correct |
20 ms |
344 KB |
# of queries: 2424 |
9 |
Correct |
24 ms |
344 KB |
# of queries: 2550 |
10 |
Correct |
16 ms |
344 KB |
# of queries: 1488 |
11 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |