Submission #658327

#TimeUsernameProblemLanguageResultExecution timeMemory
658327Zena_HossamPermutation (APIO22_perm)C++17
Compilation error
0 ms0 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);
      |             ~~^~~~
/usr/bin/ld: /tmp/ccKwASPK.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLtC1LN.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status