#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)
{
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 |
Runtime error |
18 ms |
336 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
336 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |