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 "grader.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(int N) {
vector<int> perm(N);
iota(perm.begin(), perm.end(), 1);
vector<bool> known(N, false);
int prv = -1;
for (int i = 0; i < N;) {
if (known[i]) {
i++;
continue;
}
int baseline = query(perm);
if (baseline == N) return;
int found = -1;
for (int j = i + 1; j < N; j++) if (!known[j]) {
swap(perm[i], perm[j]);
int pot = query(perm);
if (pot == N) return;
if (pot > baseline) {
found = j;
break;
}
swap(perm[i], perm[j]);
}
if (~found) {
if (~prv) known[prv] = true;
prv = found;
} else {
known[i] = true;
i++;
prv = -1;
}
}
query(perm);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |