This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define add push_back
using namespace std;
vi build(vi &alive, int i, int j) {
int N = sz(alive);
vi ret;
ret.assign(N,0);
int ind = 0;
for (int i = 0; i < N; i++) {
if (alive[i]==1 && (i <= ind && ind <= j)) {
ret[i] = 1;
ind++;
}
}
return ret;
}
void Solve(int N) {
int end = -1;
for (int i = 0; i < N; i++) {
vi nums;
nums.assign(N,1);
nums[i] = 0;
int A = Query(nums);
if (A==1) {
end = i;
break;
}
}
vi ans;
ans.add(end);
vi alive;
alive.assign(N,1);
alive[end] = 0;
for (int s = N-1; s >= 1; s--) {
int lo = 0;
int hi = s-1;
int last = ans[sz(ans)-1];
while (lo < hi) {
int m = (lo+hi)/2;
vi M = build(alive,lo,m);
int x = 1;
if (lo<m) x = Query(M);
M[last] = 1;
int y = Query(M);
if (y==x) {
hi = m;
} else {
lo = m+1;
}
}
ans.add(lo);
alive[lo] = 0;
}
for (int i = 0; i < N; i++)
ans[i]++;
Answer(ans);
}
Compilation message (stderr)
library.cpp: In function 'void Solve(int)':
library.cpp:72:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
72 | for (int i = 0; i < N; i++)
| ^~~
library.cpp:74:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
74 | Answer(ans);
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |