#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
bool ok[300];
void solve(int N) {
memset(ok, false, sizeof(ok));
vector<int> q;
for(int i = N; i >= 1; i++) {
q.push_back(i);
}
for(int i = 0; i < N; i++) {
if(ok[i]) {
continue;
}
int val = -1;
int idx1 = -1;
int idx2 = -1;
for(int j = i; j < N; j++) {
if(ok[j]) {
continue;
}
swap(q[i], q[j]);
int ret = query(q);
if(ret == N) {
return;
}
if(ret > val) {
val = ret;
idx1 = j;
idx2 = -1;
}
else if(ret == val) {
idx2 = j;
}
swap(q[i], q[j]);
}
if(idx2 == -1) {
swap(q[i], q[idx1]);
ok[i] = true;
ok[idx1] = true;
}
else {
swap(q[i], q[idx1]);
swap(q[idx1], q[idx2]);
int ret = query(q);
if(ret == N) {
return;
}
if(ret > val) {
ok[i] = true;
ok[idx2] = true;
}
else {
swap(q[idx1], q[idx2]);
swap(q[i], q[idx2]);
ok[i] = true;
ok[idx1] = true;
}
}
}
query(q);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
144 ms |
131076 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
144 ms |
131076 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
144 ms |
131076 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |