#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
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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
212 KB |
Output is correct |
7 |
Correct |
7 ms |
340 KB |
Output is correct |
8 |
Correct |
10 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
8 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
248 KB |
Output is correct |
13 |
Correct |
9 ms |
304 KB |
Output is correct |