Submission #1117572

#TimeUsernameProblemLanguageResultExecution timeMemory
1117572ereringPermutation (APIO22_perm)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; //#define int long long #define endl '\n' #define pb push_back //const int MOD=819276405795233,MAXN=1e6+5,inf=1e9+5; bool flag=1; vector<int> construct_permutation(long long k) { deque<int> dq; int cnt=-1,x=1,r=1; if(flag)r=0; flag=0; while (x-r <= k) { x *= 2; cnt++; } x-=r; x /= 2; // cout<<k<<' '<<cnt<<' '<<x<<endl; for (int i = cnt-1; i >= 0; i--)dq.push_front(i); k -= x; vector<int> v; if(k>0)v=construct_permutation(k); for(int i=0;i<v.size();i++)v[i]+=dq.size(); for(int i=0;i<dq.size();i++)v.pb(dq[i]); return v; } /*signed main() { vector<int> v=construct_permutation(14); for(auto i:v)cout<<i<<' '; }*/

Compilation message (stderr)

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