#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<int, pii>
#define pii pair<int, int>
#define fi first
#define se second
#include"library.h"
using namespace std;
const int N = 4e3+5;
const int M = 750;
const int mod = 1e9+7;
const ll base = 75;
const ll inf = 1e16+7;
int n, t, tong;
int k, m, a[N], b[N];
vector<pii> adj[N];
void Solve(int n)
{
vector<int> vi, res;
if(n == 1)
{
res.pb(1);
Answer(res);
return;
}
vi.resize(n, 1);
for(int i = 0; i < n; i ++)a[i] = 0;
for(int i = 0; i < n; i ++)
{
vi[i] = 0;
if(Query(vi) == 1)
{
a[i] = 1;
res.pb(i+1);
break;
}
vi[i] = 1;
}
for(int j = 2; j < n; j ++)
{
int l = 1, r = n-j+1, mid;
while(l <= r)
{
if(l == n-j+1)break;
mid = (l+r)>>1;
for(int i = 0, cnt = 0; i < n && cnt < mid; i ++)
if(!a[i])vi[i] = 0, ++cnt;
k = Query(vi);
vi[res.back()-1] = 1;
if(k != Query(vi))r = mid-1;
else l = mid+1;
vi[res.back()-1] = 0;
for(int i = 0, cnt = 0; i < n && cnt < mid; i ++)
if(!a[i])vi[i] = 1, ++cnt;
}
assert(l <= n-j+1);
int i = 0, cnt = 0;
while(cnt < l && i < n)
{
if(!a[i])
{
++cnt;
if(cnt == l)break;
}
++i;
}
a[i] = 1;
vi[i] = 0;
res.pb(i+1);
}
for(int i = 0; i < n; i ++)if(!a[i])res.pb(i+1);
Answer(res);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
336 KB |
# of queries: 2425 |
3 |
Correct |
36 ms |
376 KB |
# of queries: 2644 |
4 |
Correct |
35 ms |
336 KB |
# of queries: 2591 |
5 |
Correct |
35 ms |
336 KB |
# of queries: 2512 |
6 |
Correct |
31 ms |
336 KB |
# of queries: 2549 |
7 |
Correct |
39 ms |
380 KB |
# of queries: 2546 |
8 |
Correct |
51 ms |
384 KB |
# of queries: 2412 |
9 |
Correct |
34 ms |
400 KB |
# of queries: 2542 |
10 |
Correct |
19 ms |
336 KB |
# of queries: 1482 |
11 |
Correct |
0 ms |
336 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
336 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
336 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
336 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
336 KB |
# of queries: 73 |
16 |
Correct |
3 ms |
336 KB |
# of queries: 189 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
336 KB |
# of queries: 2425 |
3 |
Correct |
36 ms |
376 KB |
# of queries: 2644 |
4 |
Correct |
35 ms |
336 KB |
# of queries: 2591 |
5 |
Correct |
35 ms |
336 KB |
# of queries: 2512 |
6 |
Correct |
31 ms |
336 KB |
# of queries: 2549 |
7 |
Correct |
39 ms |
380 KB |
# of queries: 2546 |
8 |
Correct |
51 ms |
384 KB |
# of queries: 2412 |
9 |
Correct |
34 ms |
400 KB |
# of queries: 2542 |
10 |
Correct |
19 ms |
336 KB |
# of queries: 1482 |
11 |
Correct |
0 ms |
336 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
336 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
336 KB |
# of queries: 4 |
14 |
Correct |
0 ms |
336 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
336 KB |
# of queries: 73 |
16 |
Correct |
3 ms |
336 KB |
# of queries: 189 |
17 |
Correct |
425 ms |
516 KB |
# of queries: 18016 |
18 |
Correct |
410 ms |
584 KB |
# of queries: 17265 |
19 |
Correct |
357 ms |
388 KB |
# of queries: 17467 |
20 |
Correct |
415 ms |
392 KB |
# of queries: 16285 |
21 |
Correct |
359 ms |
392 KB |
# of queries: 15340 |
22 |
Correct |
341 ms |
392 KB |
# of queries: 17649 |
23 |
Correct |
392 ms |
392 KB |
# of queries: 17240 |
24 |
Correct |
126 ms |
392 KB |
# of queries: 7907 |
25 |
Correct |
418 ms |
396 KB |
# of queries: 17148 |
26 |
Correct |
345 ms |
396 KB |
# of queries: 15983 |
27 |
Correct |
137 ms |
336 KB |
# of queries: 8036 |
28 |
Correct |
397 ms |
388 KB |
# of queries: 15973 |
29 |
Correct |
369 ms |
388 KB |
# of queries: 15955 |
30 |
Correct |
405 ms |
396 KB |
# of queries: 15973 |