# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
983984 | vjudge1 | Permutation (APIO22_perm) | C++17 | 0 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 <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>
#include "perm.h"
#define ll long long
using namespace std;
std::vector<int> construct_permutation(long long k){
vector<int> ans, v;
deque<vector<int>> d;
for(ll i = 62; i >= 0; i--){
if(k >= (1ll << i)){
k -= (1ll << i);
v.push_back(i);
}
}
for(int i = 0; i < v[0]; i++) ans.push_back(i);
v.erase(v.begin());
while(!v.empty()){
int num = v.back();
vector<int> dop = ans, neww;
while(num > 0){
num--;
neww.push_back(dop.back() + 1);
dop.pop_back();
}
reverse(neww.begin(), neww.end());
for(int i = 0; i < dop.size(); i++)
dop[i]++;
ans = dop;
ans.push_back(0);
for(int to : neww)
ans.push_back(to);
v.pop_back();
}
return ans;
}
// int main(){
// ll n;
// cin >> n;
// vector<int> res = construct_permutation(n);
// for(int to : res)
// cout << to << " ";
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |