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 "perm.h"
#define pb push_back
using namespace std;
vector<int> construct_permutation(long long k){
vector<long double> tmp;
int itr = 0;
vector<int> xx;
while(k){
xx.pb(k % 4);
k /= 4;
}
reverse(xx.begin(), xx.end());
for(int m : xx){
if(!itr){
if(m == 2)
tmp = {0};
else if(m == 3){
tmp = {1, 0};
}
}
else{
if(!m){
tmp.pb(1e9);
tmp.pb(1e9 + 1);
}
else if(m == 1){
tmp.pb(1e9);
tmp.pb(1e9 + 1);
tmp.pb(-1e9);
}
else if(m == 2){
tmp.pb(1e9);
tmp.pb(-1e9);
tmp.pb(1e9 + 1);
}
else{
bool check = false;
bool g1 = false;
for(auto i : tmp){
if(i == 1)
g1 = true;
else if(i == 0){
check = g1;
break;
}
}
if(!check){
tmp.pb(1e9);
tmp.pb(-1e9);
tmp.pb(1e9 + 1);
tmp.pb(-1e9 - 1);
}
else{
tmp.pb(1e9);
tmp.pb(1e9 + 1);
tmp.pb(1.5);
}
}
}
++itr;
vector<long double> t1 = tmp;
sort(t1.begin(), t1.end());
for(auto &i : tmp)
i = lower_bound(t1.begin(), t1.end(), i) - t1.begin();
}
vector<int> ans;
vector<long double> t1 = tmp;
sort(t1.begin(), t1.end());
for(auto &i : tmp)
ans.pb(i = lower_bound(t1.begin(), t1.end(), i) - t1.begin());
// for(int i : ans)
// cout << i << " ";
// cout << "\n";
return ans;
}
//static bool check_permutation(vector<int> v)
//{
// sort(v.begin(),v.end());
// for(int i=0;i<v.size();i++)
// if(v[i]!=i) return 0;
// return 1;
//}
//
//long long count_increasing(const vector<int>& v) {
// vector<long long> dp(v.size() + 1, 0);
// dp[0] = 1;
// for (int x : v)
// {
// for (int i = 0; i <= x; i++)
// {
// dp[x+1] += dp[i];
// dp[x+1] = min(dp[x+1],1000000000000000001);
// }
// }
// long long result = 0;
// for (int i = 0; i <= (int)v.size(); i++){
// result += dp[i];
// result = min(result,1000000000000000001);
// }
// return result;
//}
//
//
//int main(){
// long long k;
// cin >> k;
// vector<int> v = construct_permutation(k);
// if(!check_permutation(v)){
// cout << k << " Not a permutation.";
// return 0;
// }
// if(count_increasing(v) != k){
// cout << "Differ.\n";
// cout << k << " " << count_increasing(v) << "\n";
// return 0;
// }
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |