#include "grader.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(int N) {
srand(69420);
vector<int> perm(N);
iota(perm.begin(), perm.end(), 1);
random_shuffle(perm.begin(), perm.end());
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
200 KB |
Correct! Number of queries: 27 |
2 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 13 |
3 |
Correct |
1 ms |
204 KB |
Correct! Number of queries: 26 |
4 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 27 |
5 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 33 |
6 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 36 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
200 KB |
Correct! Number of queries: 27 |
2 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 13 |
3 |
Correct |
1 ms |
204 KB |
Correct! Number of queries: 26 |
4 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 27 |
5 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 33 |
6 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 36 |
7 |
Correct |
23 ms |
200 KB |
Correct! Number of queries: 1300 |
8 |
Correct |
21 ms |
204 KB |
Correct! Number of queries: 1100 |
9 |
Correct |
15 ms |
200 KB |
Correct! Number of queries: 1100 |
10 |
Correct |
12 ms |
200 KB |
Correct! Number of queries: 900 |
11 |
Correct |
14 ms |
200 KB |
Correct! Number of queries: 900 |
12 |
Correct |
18 ms |
200 KB |
Correct! Number of queries: 1000 |
13 |
Correct |
15 ms |
200 KB |
Correct! Number of queries: 900 |
14 |
Correct |
20 ms |
200 KB |
Correct! Number of queries: 1100 |
15 |
Correct |
16 ms |
200 KB |
Correct! Number of queries: 1000 |
16 |
Correct |
16 ms |
200 KB |
Correct! Number of queries: 900 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
200 KB |
Correct! Number of queries: 27 |
2 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 13 |
3 |
Correct |
1 ms |
204 KB |
Correct! Number of queries: 26 |
4 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 27 |
5 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 33 |
6 |
Correct |
1 ms |
200 KB |
Correct! Number of queries: 36 |
7 |
Correct |
23 ms |
200 KB |
Correct! Number of queries: 1300 |
8 |
Correct |
21 ms |
204 KB |
Correct! Number of queries: 1100 |
9 |
Correct |
15 ms |
200 KB |
Correct! Number of queries: 1100 |
10 |
Correct |
12 ms |
200 KB |
Correct! Number of queries: 900 |
11 |
Correct |
14 ms |
200 KB |
Correct! Number of queries: 900 |
12 |
Correct |
18 ms |
200 KB |
Correct! Number of queries: 1000 |
13 |
Correct |
15 ms |
200 KB |
Correct! Number of queries: 900 |
14 |
Correct |
20 ms |
200 KB |
Correct! Number of queries: 1100 |
15 |
Correct |
16 ms |
200 KB |
Correct! Number of queries: 1000 |
16 |
Correct |
16 ms |
200 KB |
Correct! Number of queries: 900 |
17 |
Runtime error |
212 ms |
200 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |