#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int solved[260];
void solve(int N){
memset(solved,0,sizeof(solved));
vector<int> qu;
for (int x = 1; x<=N; x++){
qu.push_back(x);
}
for (int x = 0; x<N; x++){
if (solved[x]) continue;
int minv = -1;
int p1 = -1;
int p2 = -1;
for (int y = x; y<N; y++){
if (solved[y]) continue;
//printf("%d %d\n",qu[x],qu[y]);
swap(qu[x],qu[y]);
//printf("%d %d\n",qu[x],qu[y]);
int res = query(qu);
if (res==N) return;
if (res>minv){
p1 = y;
p2 = -1;
minv = res;
}
else if (res==minv){
p2 = y;
}
swap(qu[x],qu[y]);
}
//printf("%d %d pos\n",p1,p2);
if (p2==-1){
swap(qu[x],qu[p1]);
solved[x] = true;
solved[p1] = true;
}
else{
//printf("figuring out\n");
swap(qu[x],qu[p1]);
swap(qu[p1],qu[p2]);
int res = query(qu);
if (res==N) return;
if (res>minv){
solved[x] = true;
solved[p2] = true;
}
else{
swap(qu[p1],qu[p2]);
swap(qu[x],qu[p2]);
solved[x] = true;
solved[p1] = true;
}
}
}
query(qu);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 19 |
2 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 19 |
5 |
Correct |
4 ms |
304 KB |
Correct! Number of queries: 15 |
6 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 21 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 19 |
2 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 19 |
5 |
Correct |
4 ms |
304 KB |
Correct! Number of queries: 15 |
6 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 21 |
7 |
Correct |
16 ms |
384 KB |
Correct! Number of queries: 700 |
8 |
Correct |
14 ms |
256 KB |
Correct! Number of queries: 700 |
9 |
Correct |
13 ms |
384 KB |
Correct! Number of queries: 600 |
10 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
11 |
Correct |
12 ms |
384 KB |
Correct! Number of queries: 500 |
12 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
13 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 600 |
14 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
15 |
Correct |
21 ms |
384 KB |
Correct! Number of queries: 700 |
16 |
Correct |
15 ms |
360 KB |
Correct! Number of queries: 700 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Correct! Number of queries: 19 |
2 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 7 |
3 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
5 ms |
256 KB |
Correct! Number of queries: 19 |
5 |
Correct |
4 ms |
304 KB |
Correct! Number of queries: 15 |
6 |
Correct |
5 ms |
384 KB |
Correct! Number of queries: 21 |
7 |
Correct |
16 ms |
384 KB |
Correct! Number of queries: 700 |
8 |
Correct |
14 ms |
256 KB |
Correct! Number of queries: 700 |
9 |
Correct |
13 ms |
384 KB |
Correct! Number of queries: 600 |
10 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
11 |
Correct |
12 ms |
384 KB |
Correct! Number of queries: 500 |
12 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
13 |
Correct |
17 ms |
384 KB |
Correct! Number of queries: 600 |
14 |
Correct |
14 ms |
384 KB |
Correct! Number of queries: 700 |
15 |
Correct |
21 ms |
384 KB |
Correct! Number of queries: 700 |
16 |
Correct |
15 ms |
360 KB |
Correct! Number of queries: 700 |
17 |
Incorrect |
302 ms |
384 KB |
Too many queries |
18 |
Halted |
0 ms |
0 KB |
- |