Submission #658324

#TimeUsernameProblemLanguageResultExecution timeMemory
658324Zena_HossamPermutation (APIO22_perm)C++17
10 / 100
2 ms340 KiB
#include<bits/stdc++.h> #include "perm.h" //#include "grader.cpp" #define ll long long using namespace std; std::vector<int> construct_permutation(long long k) { ll p=k-2;k--; vector<int>s,x; while(1) { ll l=0,r=60,p1,h; while(l<=r) { ll mid=(l+r)/2; p1=(1<<mid)-1; if(k>=p1) { h=mid; l=mid+1; } else r=mid-1; } for(ll i=p-h+1;i<=p;i++){ s.push_back(i); } // cout<<v[o].first<<" "<<v[o].second<<" "<<k<<"\n"; p-=h; k-=((1<<h)-1); if(k<=0)break; }x=s; sort(x.begin(),x.end()); map<ll,ll>m; for(ll i=0;i<x.size();i++) { m[x[i]]=i; } for(ll i=0;i<x.size();i++) { s[i]=m[s[i]]; } return s; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:34:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(ll i=0;i<x.size();i++)
      |                ~^~~~~~~~~
perm.cpp:38:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(ll i=0;i<x.size();i++)
      |                ~^~~~~~~~~
perm.cpp:29:15: warning: 'h' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |         k-=((1<<h)-1);
      |             ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...