#include <bits/stdc++.h>
#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);
if(n == 1){
ans[0] = 1;
Answer(ans);
return;
}
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() - 1;
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 |
27 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
24 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
33 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
23 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
38 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
16 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
17 ms |
596 KB |
# of queries: 2420 |
9 |
Correct |
29 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
344 KB |
# of queries: 1474 |
11 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
344 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 77 |
16 |
Correct |
3 ms |
344 KB |
# of queries: 183 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
24 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
33 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
23 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
38 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
16 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
17 ms |
596 KB |
# of queries: 2420 |
9 |
Correct |
29 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
344 KB |
# of queries: 1474 |
11 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
344 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 77 |
16 |
Correct |
3 ms |
344 KB |
# of queries: 183 |
17 |
Correct |
303 ms |
344 KB |
# of queries: 17982 |
18 |
Correct |
278 ms |
344 KB |
# of queries: 17293 |
19 |
Correct |
292 ms |
340 KB |
# of queries: 17467 |
20 |
Correct |
290 ms |
344 KB |
# of queries: 16325 |
21 |
Correct |
291 ms |
344 KB |
# of queries: 15324 |
22 |
Correct |
336 ms |
344 KB |
# of queries: 17669 |
23 |
Correct |
319 ms |
344 KB |
# of queries: 17224 |
24 |
Correct |
121 ms |
344 KB |
# of queries: 7915 |
25 |
Correct |
313 ms |
344 KB |
# of queries: 17136 |
26 |
Correct |
317 ms |
344 KB |
# of queries: 15963 |
27 |
Correct |
138 ms |
344 KB |
# of queries: 8040 |
28 |
Correct |
288 ms |
344 KB |
# of queries: 15957 |
29 |
Correct |
291 ms |
344 KB |
# of queries: 15939 |
30 |
Correct |
330 ms |
344 KB |
# of queries: 15957 |