#include <iostream>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int maxn = 1010;
int ans[maxn];
int n;
inline int bisect(int x)
{
vector<int> c1(n, 0);
vector<int> rem;
for(int i = 0; i < x; i++)
c1[ans[i]] = 1;
for(int i = 0; i < n; i++)
if(!c1[i])
rem.push_back(i);
int down = 0;
int up = rem.size();
while(up-down > 1)
{
int mid = (up+down) / 2;
vector<int> m1 = c1;
vector<int> m2(n, 0);
for(int j = down; j < mid; j++)
{
m1[rem[j]] = 1;
m2[rem[j]] = 1;
}
if(Query(m1) == Query(m2))
up = mid;
else
down = mid;
}
return rem[down];
}
void Solve(int N)
{
n = N;
if(n == 1)
return Answer({1});
for(int i = 0; i < n; i++)
{
vector<int> m(n, 1);
m[i] = 0;
if(Query(m) == 1)
{
ans[0] = i;
break;
}
}
for(int i = 1; i < n; i++)
ans[i] = bisect(i);
vector<int> A(n);
for(int i = 0; i < n; i++)
A[i] = ans[i]+1;
Answer(A);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
208 KB |
# of queries: 2375 |
2 |
Correct |
27 ms |
212 KB |
# of queries: 2409 |
3 |
Correct |
34 ms |
304 KB |
# of queries: 2648 |
4 |
Correct |
35 ms |
300 KB |
# of queries: 2595 |
5 |
Correct |
38 ms |
208 KB |
# of queries: 2508 |
6 |
Correct |
35 ms |
208 KB |
# of queries: 2551 |
7 |
Correct |
42 ms |
208 KB |
# of queries: 2544 |
8 |
Correct |
32 ms |
208 KB |
# of queries: 2420 |
9 |
Correct |
25 ms |
208 KB |
# of queries: 2546 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1474 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 77 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 183 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
208 KB |
# of queries: 2375 |
2 |
Correct |
27 ms |
212 KB |
# of queries: 2409 |
3 |
Correct |
34 ms |
304 KB |
# of queries: 2648 |
4 |
Correct |
35 ms |
300 KB |
# of queries: 2595 |
5 |
Correct |
38 ms |
208 KB |
# of queries: 2508 |
6 |
Correct |
35 ms |
208 KB |
# of queries: 2551 |
7 |
Correct |
42 ms |
208 KB |
# of queries: 2544 |
8 |
Correct |
32 ms |
208 KB |
# of queries: 2420 |
9 |
Correct |
25 ms |
208 KB |
# of queries: 2546 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1474 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 77 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 183 |
17 |
Correct |
435 ms |
300 KB |
# of queries: 17982 |
18 |
Correct |
429 ms |
208 KB |
# of queries: 17293 |
19 |
Correct |
480 ms |
304 KB |
# of queries: 17467 |
20 |
Correct |
384 ms |
308 KB |
# of queries: 16325 |
21 |
Correct |
377 ms |
308 KB |
# of queries: 15324 |
22 |
Correct |
442 ms |
304 KB |
# of queries: 17669 |
23 |
Correct |
380 ms |
208 KB |
# of queries: 17224 |
24 |
Correct |
174 ms |
208 KB |
# of queries: 7915 |
25 |
Correct |
438 ms |
308 KB |
# of queries: 17136 |
26 |
Correct |
374 ms |
296 KB |
# of queries: 15963 |
27 |
Correct |
139 ms |
208 KB |
# of queries: 8040 |
28 |
Correct |
416 ms |
208 KB |
# of queries: 15957 |
29 |
Correct |
329 ms |
208 KB |
# of queries: 15939 |
30 |
Correct |
393 ms |
208 KB |
# of queries: 15957 |