# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916435 | Jakub_Wozniak | Permutation (APIO22_perm) | C++17 | 1 ms | 348 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>
using namespace std;
vector <pair<int,int>> V;
vector<int> construct_permutation(long long n)
{
long long MAX = 300;
vector <int> v;
vector <bool> B;
int R = n%3;
int r[200];
n /= 3;
if(R)v.push_back(R);
while (n)
{
if(n < 4)
{
if(n < 2)break;
if (n % 4 == 3) v.push_back(1);
v.push_back(MAX);
MAX--;
break;
}
if (n % 4 == 1) v.push_back(1);
if (n % 4 == 3) v.push_back(3);
v.push_back(MAX);
MAX--;
if (n % 4 == 2) v.push_back(1);
v.push_back(MAX);
MAX--;
n /= 4;
}
v.push_back(1);
v.push_back(2);
reverse(v.begin() , v.end());
for(int i = 0 ; i < v.size() ; i++)
{
V.push_back({v[i],-i});
}
sort(V.begin() , V.end());
long long akt = 0;
for(int i = 0 ; i < V.size() ;i++)
{
r[-V[i].second] = akt;
akt++;
}
for(int i = 0 ; i < V.size() ; i++)
{
v[i] = r[i];
}
V.clear();
return v;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |