# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
907361 | Tymond | 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>
#include "perm.h"
using namespace std;
using ll = long long;
using ld = long double;
const ld INF = 1e9;
void zmien(vector<ld>& a){
vector<ld> nasz = a;
sort(nasz.begin(), nasz.end());
for(int i = 0; i < (int)a.size(); i++){
for(int j = 0; j < nasz.size(); j++){
if(a[i] == nasz[j]){
a[i] = j;
break;
}
}
}
}
vector<signed> construct_permutation(ll k){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int aktBit = 0;
ll pot = 1;
while(pot * 2 <= k){
aktBit++;
pot *= 2;
}
vector<ld> ans;
bool bylo = false;
while(aktBit > 0){
aktBit -= 2;
if(aktBit == -1){
//został jeden na końcu
ans.push_back(INF);//n * 2
if(k & (1 << (aktBit + 1))){
ans.push_back(-INF);//n + 1
}
zmien(ans);
continue;
}
int kon = (k >> aktBit) & 3;
if(kon == 0){
//n * 4
ans.push_back(INF);
ans.push_back(INF + 1);
}else if(kon == 1){
//n * 4 + 1
ans.push_back(INF);
ans.push_back(INF + 1);
ans.push_back(-INF);
bylo = true;
}else if(kon == 2){
//n * 4 + 2
ans.push_back(INF);
ans.push_back(-INF);
ans.push_back(INF + 1);
bylo = true;
}else if(kon == 3){
//4 * n + 3
if(bylo){
ans.push_back(INF);
ans.push_back(-INF);
ans.push_back(INF + 1);
ans.push_back(-INF - 1);
bylo = true;
}else{
ans.push_back(INF);
ans.push_back(INF + 1);
ans.push_back(0.5);
}
}
zmien(ans);
}
return vector<signed> (ans.begin(), ans.end());
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |