# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
644248 | Karuk | Secret Permutation (RMI19_permutation) | C++14 | 0 ms | 208 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<bits/stdc++.h>
#include "permutationc.h"
using namespace std;
void solve(int n) {
int a[n];
for(int i=1;i<=n;i++) {
a[i-1]=i;
}
int maxres=0,maxind=-1;
for(int i=1;i<n;i++) {
reverse(a,a+i);
int c=query(a);
reverse(a,a+i);
if(c>maxres){maxres=c;maxind=i;}
}
swap(a[0],a[maxind]);
maxres=0;
maxind=-1;
vector<pair<int,int> >v;
for(int i=1;i<n;i++) {
reverse(a,a+i);
int c=query(a);
reverse(a,a+i);
v.push_back({c,a[i]});
}
int ans[n];
sort(v.begin(),v.end());
ans[a[0]]=1;
for(int i=2;i<=n;i++) {
ans[v[i-2].second]=i;
}
answer(ans);
}
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... |