#include "library.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> v, zero, tmp, ans;
void Solve(int n)
{
for (int i=1; i<=n; i++)
{
v.push_back(i);
zero.push_back(0);
}
for (int i=0; i<n; i++)
{
int l=0, r=n-i-1;
while (l<r)
{
int m=(l+r)/2, res1, res2;
tmp=zero;
for (int j=l; j<=m; j++)
tmp[v[j]-1]=1;
res1=Query(tmp);
if (i)
tmp[ans[i-1]-1]=1;
else
for (int j=0; j<n; j++)
tmp[j]^=1;
res2=Query(tmp);
if (res1>=res2)
r=m;
else
l=m+1;
}
ans.push_back(v[l]);
v.erase(v.begin()+l);
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
300 KB |
# of queries: 2386 |
2 |
Correct |
34 ms |
280 KB |
# of queries: 2378 |
3 |
Correct |
33 ms |
208 KB |
# of queries: 2512 |
4 |
Correct |
29 ms |
208 KB |
# of queries: 2516 |
5 |
Correct |
36 ms |
280 KB |
# of queries: 2514 |
6 |
Correct |
32 ms |
208 KB |
# of queries: 2516 |
7 |
Correct |
30 ms |
296 KB |
# of queries: 2522 |
8 |
Correct |
21 ms |
284 KB |
# of queries: 2388 |
9 |
Correct |
30 ms |
288 KB |
# of queries: 2476 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1458 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
208 KB |
# of queries: 6 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 10 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 80 |
16 |
Correct |
2 ms |
208 KB |
# of queries: 188 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
300 KB |
# of queries: 2386 |
2 |
Correct |
34 ms |
280 KB |
# of queries: 2378 |
3 |
Correct |
33 ms |
208 KB |
# of queries: 2512 |
4 |
Correct |
29 ms |
208 KB |
# of queries: 2516 |
5 |
Correct |
36 ms |
280 KB |
# of queries: 2514 |
6 |
Correct |
32 ms |
208 KB |
# of queries: 2516 |
7 |
Correct |
30 ms |
296 KB |
# of queries: 2522 |
8 |
Correct |
21 ms |
284 KB |
# of queries: 2388 |
9 |
Correct |
30 ms |
288 KB |
# of queries: 2476 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1458 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
208 KB |
# of queries: 6 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 10 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 80 |
16 |
Correct |
2 ms |
208 KB |
# of queries: 188 |
17 |
Correct |
207 ms |
300 KB |
# of queries: 17168 |
18 |
Correct |
222 ms |
312 KB |
# of queries: 16944 |
19 |
Correct |
278 ms |
208 KB |
# of queries: 17166 |
20 |
Correct |
229 ms |
296 KB |
# of queries: 15996 |
21 |
Correct |
252 ms |
328 KB |
# of queries: 15080 |
22 |
Correct |
210 ms |
296 KB |
# of queries: 17158 |
23 |
Correct |
278 ms |
332 KB |
# of queries: 17110 |
24 |
Correct |
107 ms |
296 KB |
# of queries: 7834 |
25 |
Correct |
263 ms |
300 KB |
# of queries: 16762 |
26 |
Correct |
193 ms |
420 KB |
# of queries: 15634 |
27 |
Correct |
63 ms |
208 KB |
# of queries: 7756 |
28 |
Correct |
182 ms |
208 KB |
# of queries: 17954 |
29 |
Correct |
239 ms |
304 KB |
# of queries: 17934 |
30 |
Correct |
273 ms |
296 KB |
# of queries: 17954 |