Submission #586533

#TimeUsernameProblemLanguageResultExecution timeMemory
586533jamezzzPermutation (APIO22_perm)C++17
100 / 100
10 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() #define pb push_back typedef long long ll; vector<int> construct_permutation(ll k){ vector<int> b4; while(k){ b4.pb((int)(k%4)); k/=4; } vector<double> ans; if(b4.back()==2)ans.pb(0); else if(b4.back()==3)ans.pb(1),ans.pb(0); b4.pop_back(); while(!b4.empty()){ if(b4.back()==0)ans.pb(1e9),ans.pb(1e9+1); else if(b4.back()==1)ans.pb(1e9),ans.pb(1e9+1),ans.pb(-1); else if(b4.back()==2)ans.pb(1e9),ans.pb(-1),ans.pb(1e9+1); else{ int p0=-1,p1=1e9; for(int i=0;i<ans.size();++i){ if(ans[i]==0)p0=i; if(ans[i]==1)p1=i; } if(p1<p0)ans.pb(1e9),ans.pb(1e9+1),ans.pb(1.5); else ans.pb(1e9),ans.pb(-1),ans.pb(1e9+1),ans.pb(-2); } b4.pop_back(); vector<double> srt; for(auto x:ans)srt.pb(x); sort(all(srt)); for(auto &x:ans)x=lower_bound(all(srt),x)-srt.begin(); } return vector<int>(all(ans)); }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    for(int i=0;i<ans.size();++i){
      |                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...