This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
while(1){
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(check[i]||check[j])
continue;
swap(vec[i],vec[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[i],vec[j]);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |