#pragma GCC optimize("Ofast")
#include "grader.h"
#include<stdio.h>
#include<algorithm>
#include<assert.h>
using namespace std;
int num[500];
bool check[500],wrong[500];
void solve(int n){
int i,j;
for(i=0;i<n;i++)
wrong[i]=check[i]=0;
vector<int> vec(n);
for(i=0;i<n;i++)
vec[i]=i+1;
random_shuffle(vec.begin(),vec.end());
int now=query(vec);
if(now==n)
return;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
swap(vec[j],vec[i]);
int v=query(vec);
if(v==n)
return;
if(v==now-2)
check[i]=check[j]=1;
else if(v==now)
wrong[i]=wrong[j]=1;
swap(vec[i],vec[j]);
}
}
vector<int> order;
for(i=0;i<n;i++)
if(wrong[i])
order.emplace_back(i);
for(i=0;i<n;i++)
check[i]=0;
while(1){
for(i=0;i<(int)order.size();i++){
for(j=i+1;j<(int)order.size();j++){
if(check[i]||check[j])
continue;
swap(vec[order[i]],vec[order[j]]);
int v=query(vec);
if(v==n)
return;
if(v==now+2){
now+=2;
check[i]=check[j]=1;
break;
}
else if(v==now+1)
now++;
else
swap(vec[order[i]],vec[order[j]]);
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 31 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 25 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
6 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 31 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 25 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
6 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
7 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
8 |
Correct |
24 ms |
256 KB |
Correct! Number of queries: 2400 |
9 |
Correct |
27 ms |
256 KB |
Correct! Number of queries: 2000 |
10 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2300 |
11 |
Correct |
22 ms |
256 KB |
Correct! Number of queries: 1600 |
12 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
13 |
Correct |
28 ms |
256 KB |
Correct! Number of queries: 2000 |
14 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
15 |
Correct |
44 ms |
256 KB |
Correct! Number of queries: 2400 |
16 |
Correct |
43 ms |
256 KB |
Correct! Number of queries: 2300 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 31 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 25 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 32 |
6 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
7 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
8 |
Correct |
24 ms |
256 KB |
Correct! Number of queries: 2400 |
9 |
Correct |
27 ms |
256 KB |
Correct! Number of queries: 2000 |
10 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2300 |
11 |
Correct |
22 ms |
256 KB |
Correct! Number of queries: 1600 |
12 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
13 |
Correct |
28 ms |
256 KB |
Correct! Number of queries: 2000 |
14 |
Correct |
33 ms |
256 KB |
Correct! Number of queries: 2400 |
15 |
Correct |
44 ms |
256 KB |
Correct! Number of queries: 2400 |
16 |
Correct |
43 ms |
256 KB |
Correct! Number of queries: 2300 |
17 |
Execution timed out |
3035 ms |
256 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |