# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094310 | alexdd | Secret Permutation (RMI19_permutation) | C++17 | 1 ms | 600 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;
map<vector<int>,int> mp;
int intreaba(vector<int> aux)
{
if(mp[aux]==0)
{
mp[aux] = query(aux);
}
return mp[aux];
}
void solve(int N)
{
mp.clear();
vector<int> v(N);
for(int i=0;i<N;i++)
v[i]=i+1;
while(intreaba(v) > N-1)
{
bool schimbat=0;
for(int i=0;i<N;i++)
{
for(int j=i+1;j<N;j++)
{
int init = intreaba(v);
swap(v[i],v[j]);
if(intreaba(v) >= init)
swap(v[i],v[j]);
else
schimbat=1;
}
}
assert(schimbat);
}
vector<int> rez(N);
for(int i=0;i<N;i++)
rez[v[i]-1]=i+1;
answer(rez);
}
/*
7
2 1 3 7 4 6 5
*/
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... |