#include <bits/stdc++.h>
#define TASK "kajsdkjd"
#include "library.h"
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define all(C) C.begin(), C.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INT_LIM = 2147483647;
const ll LL_LIM = 9223372036854775807;
template <typename X> bool minimize(X &x, const X &y) {if (x>y){x = y; return true;}return false;}
template <typename X> bool maximize(X &x, const X &y) {if (x<y){x = y; return true;}return false;}
///------------------------------------------///
vector<int> candidate;
vector<int> ans;
void eraseVal(int val) {
auto it = find(candidate.begin(), candidate.end(), val);
if (it != candidate.end()) {
candidate.erase(it);
}
}
void Solve(int N)
{
ans.clear();
candidate.clear();
vector<int> ask;
FOR(i, 1, N)
{
ask.pb(1);
candidate.pb(i);
}
FOR(i, 1, N)
{
ask[i-1] = 0;
if (Query(ask)==1)
{
ans.pb(i); break;
}
ask[i-1] = 1;
}
if (ans.empty()) return;
eraseVal(ans[0]);
FOR(i, 2, N)
{
int l = 0, r = candidate.size()-1, ret = 0;
while (l<=r)
{
FOR(t, 0, N-1) ask[t] = 0;
int mid = (l+r)>>1;
FOR(t, 0, mid) ask[candidate[t]-1] = 1;
int v1 = Query(ask), v2;
for (auto t:ans) ask[t-1] = 1;
v2 = Query(ask);
if (v1>v2) return;
if (v1==v2)
{
ret = mid;
r = mid-1;
}
else l = mid+1;
}
ans.pb(candidate[ret]);
eraseVal(candidate[ret]);
}
// for (auto i:ans) cerr << i << ' ';
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |