#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, ans, tong;
int k, m, a[N], b[N];
vector<pii> adj[N];
void Solve(int n)
{
vector<int> vi, res;
vi.resize(n, 0);
for(int i = 0; i < n; i ++)a[i] = 0;
for(int i = 0; i < n; i ++)
{
vi[i] = 1;
if(Query(vi) == 1)
{
a[i] = 1;
res.pb(i+1);
break;
}
vi[i] = 0;
}
if(n == 1)
{
Answer(res);
return;
}
for(int i = 0; i < n; i ++)
{
if(i+1 == res.back())continue;
vi[i] = 1;
if(Query(vi) == 1)
{
res.pb(i+1);
a[i] = 1;
break;
}
vi[i] = 0;
}
vi[res[0]-1] = vi[res[1]-1] = 0;
for(int j = 3; 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] = 1, ++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] = 0, ++cnt;
}
int i = 0, cnt = 0;
while(cnt < l)
{
if(!a[i])
{
++cnt;
if(cnt == l)break;
}
++i;
}
a[i] = 1;
assert(i >= 0 && i < n);
res.pb(i+1);
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
648 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
648 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |