#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;
for(i=0;i<(int)order.size();i++){
for(j=i+1;j<(int)order.size();j++){
if(check[order[j]])
continue;
swap(vec[order[i]],vec[order[j]]);
int v=query(vec);
if(v==n)
return;
if(v==now+2){
now+=2;
check[order[i]]=check[order[j]]=1;
break;
}
swap(vec[order[i]],vec[order[j]]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |