Submission #1061287

#TimeUsernameProblemLanguageResultExecution timeMemory
1061287KasymKPermutation (APIO22_perm)C++17
28.86 / 100
2 ms604 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} vector<int> construct_permutation(ll k){ if(k <= 5000){ vector<int> A; for(int i = k-2; i >= 0; --i) A.pb(i); return A; } vector<int> A; int sm = 0, sm_ = 0; bool ok = false; vector<int> answer; for(int i = 60; i >= 0; --i){ if(ok){ A.pb(sm); sm++; if(k>>i&1){ sm_--; A.pb(sm_); } } if(k>>i&1) ok = true; } for(auto &i : A) answer.pb(i-sm_); return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...