Submission #658331

#TimeUsernameProblemLanguageResultExecution timeMemory
658331Zena_HossamPermutation (APIO22_perm)C++17
10 / 100
202 ms262144 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=100,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; } for(ll i=0;i<s.size();i++) { s[i]-=(p+1); } return s; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:32:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(ll i=0;i<s.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...