#include "bits/stdc++.h"
#include "grader.h"
int query(vector<int> v);
typedef long long ll;
#define pb push_back
vector<int>v,a[5],h;
ll f[307];
void solve(int n){
for(int i=1;i<=n;i++){
v.pb(i);
}
for(int i=0;i<n;i++){
ll x=rand()%n;
ll y=rand()%n;
swap(v[x],v[y]);
}
ll x=query(v);
if(x==n)return ;
for(int i=1;i<n;i++){
swap(v[0],v[i]);
ll y=query(v);
a[y-x+2].pb(i);
swap(v[0],v[i]);
}
if(a[2].size()==0 && a[3].size()==0 && a[4].size()==0){
f[0]=1;
for(auto it:a[0]){
f[it]=1;
}
}else{
for(auto it:a[1]){
f[it]=1;
}
if(a[4].size()==1){
swap(v[0],v[a[4][0]]);
f[0]=1;
f[a[4][0]]=1;
x+=2;
}else{
swap(v[0],v[a[3][0]]);
swap(v[0],v[a[3][1]]);
ll y=query(v);
if(y-x==2){
f[0]=1;
f[a[3][0]]=1;
x=y;
}else if(y-x==3){
f[0]=1;
f[a[3][0]]=1;
f[a[3][1]]=1;
x=y;
}else{
swap(v[0],v[a[3][1]]);
swap(v[0],v[a[3][0]]);
swap(v[0],v[a[3][1]]);
swap(v[0],v[a[3][0]]);
y=query(v);
if(y-x==2){
f[0]=1;
f[a[3][1]]=1;
x=y;
}else if(y-x==3){
f[0]=1;
f[a[3][0]]=1;
f[a[3][1]]=1;
x=y;
}
}
}
}
h.pb(0);
while(h.size()>0){
h.clear();
for(int i=0;i<n;i++){
if(f[i]==0){
h.pb(i);
//cout<<i<<" ";
}
}
for(int i=0;i<n;i++){
ll x1=rand()%h.size();
ll y1=rand()%h.size();
swap(h[x1],h[y1]);
}
for(int i=1;i<h.size();i++){
swap(v[h[i-1]],v[h[i]]);
}
if(h.size()!=2)swap(v[h[0]],v[h[h.size()-1]]);
ll y=query(v);
if(y==n)return ;
if(x!=y){
for(auto i:h){
swap(v[0],v[i]);
ll z=query(v);
if(z-y==-2){
f[i]=1;
}
swap(v[0],v[i]);
}
}
}
return ;
}
Compilation message
mouse.cpp: In function 'void solve(int)':
mouse.cpp:93:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
93 | for(int i=1;i<h.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 26 |
2 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 6 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 22 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 26 |
2 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 6 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 22 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
7 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 800 |
8 |
Correct |
29 ms |
208 KB |
Correct! Number of queries: 1700 |
9 |
Correct |
18 ms |
208 KB |
Correct! Number of queries: 1200 |
10 |
Correct |
19 ms |
208 KB |
Correct! Number of queries: 1200 |
11 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1000 |
12 |
Correct |
14 ms |
208 KB |
Correct! Number of queries: 1100 |
13 |
Correct |
15 ms |
208 KB |
Correct! Number of queries: 1300 |
14 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1100 |
15 |
Correct |
20 ms |
208 KB |
Correct! Number of queries: 1400 |
16 |
Correct |
16 ms |
208 KB |
Correct! Number of queries: 1200 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 26 |
2 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 6 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 22 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 21 |
7 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 800 |
8 |
Correct |
29 ms |
208 KB |
Correct! Number of queries: 1700 |
9 |
Correct |
18 ms |
208 KB |
Correct! Number of queries: 1200 |
10 |
Correct |
19 ms |
208 KB |
Correct! Number of queries: 1200 |
11 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1000 |
12 |
Correct |
14 ms |
208 KB |
Correct! Number of queries: 1100 |
13 |
Correct |
15 ms |
208 KB |
Correct! Number of queries: 1300 |
14 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1100 |
15 |
Correct |
20 ms |
208 KB |
Correct! Number of queries: 1400 |
16 |
Correct |
16 ms |
208 KB |
Correct! Number of queries: 1200 |
17 |
Runtime error |
175 ms |
288 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |