Submission #745168

#TimeUsernameProblemLanguageResultExecution timeMemory
745168Dan4LifePermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb push_back #define all(a) begin(a), end(a) vector<int> construct_permutation(ll n) { vector<double> v; v.clear(); vector<int> A,D; A.clear(); D.clear(); while(n>0) D.pb(n%4),n/=4; reverse(all(D)); int cnt = 0; int T=0, k=0, X = -1; double t3 = 1.95; for(auto u : D){ if(!cnt){ if(u==2) v.pb(0),T=1; else if(u==3) v.pb(1), v.pb(0),T=2, k=1; //if(u==3) cout << "3! "; cnt = 1; } else{ if(u==0) v.pb(T++), v.pb(T++); else if(u==1) v.pb(T++), v.pb(T++), v.pb(X--); else if(u==2) v.pb(T++), v.pb(X--), v.pb(T++); //else if(k) v.pb(T++), v.pb(T++), v.pb(t3), t3-=0.01; else v.pb(T++), v.pb(X--), v.pb(T++), v.pb(X--), t3=0.95, k=1; } } auto w = v; sort(all(w)); for(auto u : v) A.pb(lower_bound(all(w),u)-begin(w)); return A; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:13:24: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   13 |  int cnt = 0; int T=0, k=0, X = -1;
      |                        ^
perm.cpp:14:9: warning: variable 't3' set but not used [-Wunused-but-set-variable]
   14 |  double t3 = 1.95;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...