#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 k, m, a[N], b[N];
vector<pii> adj[N];
void Solve(int n)
{
vector<int> vi, res;
vi.resize(n, 0);
fill_n(a, n+1, 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;
}
for(int j = 2; j <= n; j ++)
{
int l = 1, r = n-j+1, mid;
vi[res[j-2]-1] = 0;
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[j-2]-1] = 1;
if(k == Query(vi))r = mid-1;
else l = mid+1;
vi[res[j-2]-1] = 0;
for(int i = 0, cnt = 0; i < n && cnt < mid; i ++)
if(!a[i])vi[i] = 0, ++cnt;
}
vi[res[j-2]-1] = 1;
int i = 0, cnt = 0;
while(cnt < l)
{
if(!a[i])++cnt;
++i;
}
--i;
a[i] = 1;
vi[i] = 1;
res.pb(i+1);
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
336 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
336 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |