#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
void solve(int n){
mt19937 rng(999);
int perm[n];
for(int i=0; i<n; i++) perm[i]=i+1;
shuffle(perm,perm+n,rng);
vector<int> adj[n];
vector<int> v;
for(int i=0; i<n; i++) v.push_back(perm[i]);
int x=query(v);
int done[n];
memset(done,0,sizeof(done));
for(int i=0; i<n; i++){
if(done[i]) continue;
for(int j=i+1; j<n; j++){
if(done[j]) continue;
swap(v[i],v[j]);
int y=query(v);
if(y==n) return;
if(y>x){
if(y==x+2){
done[j]=1;
x=y;
break;
}
x=y;
continue;
}
swap(v[i],v[j]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 13 |
2 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 7 |
3 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 9 |
4 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 22 |
5 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 6 |
6 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 13 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 13 |
2 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 7 |
3 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 9 |
4 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 22 |
5 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 6 |
6 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 13 |
7 |
Correct |
7 ms |
344 KB |
Correct! Number of queries: 1100 |
8 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
7 ms |
340 KB |
Correct! Number of queries: 1100 |
10 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1100 |
11 |
Correct |
6 ms |
344 KB |
Correct! Number of queries: 800 |
12 |
Correct |
7 ms |
344 KB |
Correct! Number of queries: 1100 |
13 |
Correct |
10 ms |
344 KB |
Correct! Number of queries: 1000 |
14 |
Correct |
9 ms |
344 KB |
Correct! Number of queries: 1200 |
15 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1200 |
16 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1300 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 13 |
2 |
Correct |
1 ms |
344 KB |
Correct! Number of queries: 7 |
3 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 9 |
4 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 22 |
5 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 6 |
6 |
Correct |
0 ms |
344 KB |
Correct! Number of queries: 13 |
7 |
Correct |
7 ms |
344 KB |
Correct! Number of queries: 1100 |
8 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
7 ms |
340 KB |
Correct! Number of queries: 1100 |
10 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1100 |
11 |
Correct |
6 ms |
344 KB |
Correct! Number of queries: 800 |
12 |
Correct |
7 ms |
344 KB |
Correct! Number of queries: 1100 |
13 |
Correct |
10 ms |
344 KB |
Correct! Number of queries: 1000 |
14 |
Correct |
9 ms |
344 KB |
Correct! Number of queries: 1200 |
15 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1200 |
16 |
Correct |
8 ms |
344 KB |
Correct! Number of queries: 1300 |
17 |
Runtime error |
112 ms |
420 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |