#include "grader.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(int N) {
vector<int> perm(N), pot(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]);
pot[j] = query(perm);
if (pot[j] == N) return;
if (pot[j] > baseline) {
found = j;
break;
}
swap(perm[i], perm[j]);
}
if (~found) {
for (int j = i + 1; j < N; j++) if (!known[j] && pot[j] < baseline)
known[j] = true;
if (~prv) known[prv] = true;
prv = found;
} else {
known[i] = true;
i++;
prv = -1;
}
}
query(perm);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |