#include <bits/stdc++.h>
#include "grader.h"
int n;
int Query(vector<int> q){
int k = query(q);
if (k == n) exit(0);
else return k;
}
void solve(int N){
n = N;
vector<int> q(N);
for (int i = 0; i < N; i++){
q[i] = i+1;
}
vector<int> done(N,0);
for (int i = 0; i < N; i++){
if (done[i]) continue;
int cur = Query(q);
vector<int> C;
for (int j = i+1; j < N ;j++){
swap(q[i],q[j]);
int K = Query(q) - cur;
if (K == 2){
done[i] = done[j] = 1;
break;
}
else if (K == -2){
swap(q[i],q[j]);
done[i] = done[j] = 1;
break;
}
else if (K == 1){
C.push_back(j);
}
swap(q[i],q[j]);
}
if (C.size() == 2){
swap(q[i],q[C[0]]);
swap(q[i],q[C[1]]);
int K = Query(q) - cur;
if (K == 3){
done[i] =done[C[0]] = done[C[1]] = 1;
}
else if (K == 2){
done[i] = done[C[0]] = 1;
}
else{
swap(q[i],q[C[1]]);
swap(q[i],q[C[0]]);
swap(q[i],q[C[1]]);
swap(q[i],q[C[0]]);
done[i] = done[C[1]] = 1;
}
}
done[i] = 1;
}
for (int i = 0; i < N; i++) assert(done[i]);
Query(q);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
2 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 16 |
4 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
5 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 15 |
6 |
Correct |
4 ms |
384 KB |
Correct! Number of queries: 10 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
2 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 16 |
4 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
5 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 15 |
6 |
Correct |
4 ms |
384 KB |
Correct! Number of queries: 10 |
7 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 900 |
8 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 1000 |
9 |
Correct |
18 ms |
384 KB |
Correct! Number of queries: 800 |
10 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 900 |
11 |
Correct |
13 ms |
256 KB |
Correct! Number of queries: 600 |
12 |
Correct |
16 ms |
256 KB |
Correct! Number of queries: 900 |
13 |
Correct |
14 ms |
256 KB |
Correct! Number of queries: 800 |
14 |
Correct |
18 ms |
256 KB |
Correct! Number of queries: 900 |
15 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 900 |
16 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 800 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
2 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 16 |
4 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 20 |
5 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 15 |
6 |
Correct |
4 ms |
384 KB |
Correct! Number of queries: 10 |
7 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 900 |
8 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 1000 |
9 |
Correct |
18 ms |
384 KB |
Correct! Number of queries: 800 |
10 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 900 |
11 |
Correct |
13 ms |
256 KB |
Correct! Number of queries: 600 |
12 |
Correct |
16 ms |
256 KB |
Correct! Number of queries: 900 |
13 |
Correct |
14 ms |
256 KB |
Correct! Number of queries: 800 |
14 |
Correct |
18 ms |
256 KB |
Correct! Number of queries: 900 |
15 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 900 |
16 |
Correct |
17 ms |
256 KB |
Correct! Number of queries: 800 |
17 |
Incorrect |
363 ms |
256 KB |
Too many queries |
18 |
Halted |
0 ms |
0 KB |
- |