# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259589 | cheeheng | Secret Permutation (RMI19_permutation) | C++14 | 5058 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "permutation.h"
#include <bits/stdc++.h>
using namespace std;
int tempV[10005][505];
int temp[10005];
void solve(int N){
vector<int> V;
vector<int> P;
for(int i = 1; i <= N; i ++){
V.push_back(i);
P.push_back(i);
}
//printf("P.size() = %d\n", (int)P.size());
for(int i = 0; i < N; i ++){
random_shuffle(V.begin(), V.end());
temp[i] = query(V);
for(int j = 0; j < N; j ++){
tempV[i][j] = V[j];
}
}
sort(P.begin(), P.end());
do{
bool boleh = true;
for(int j = 0; j < N; j ++){
int tempAns = 0;
for(int i = 0; i < N-1; i ++){
tempAns += abs(P[tempV[j][i]-1] - P[tempV[j][i + 1]-1]);
}
if(tempAns != temp[j]){
boleh = false;
break;
}
}
/*
for(int k: P){
printf("%d ", k);
}
printf("\n");
*/
if(boleh){
answer(P);
}
}while(next_permutation(P.begin(), P.end()));
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |