Submission #638464

#TimeUsernameProblemLanguageResultExecution timeMemory
638464Tuanlinh123Permutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define pll pair<ll,ll> #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; vector <int> construct_permutation (ll k) { ll crr=1, cnt=1; vector <int> ans; while (1) { crr*=2; if (crr>k) break; ans.pb(cnt); cnt+=2; } k-=crr/2; cnt=0; vector <int> ans1; while (k>0) { if (k&1) ans1.pb(cnt); cnt+=2; k/=2; } reverse(ans1.begin(), ans1.end()); for (ll i=0; i<ans1.size(); i++) ans.pb(ans1[i]); ll aa[1000]={}; vector <int> a(ans.begin(), ans.end()); sort(a.begin(), a.end()); for (ll i=0; i<a.size(); i++) aa[a[i]]=i; for (ll i=0; i<ans.size(); i++) ans[i]=aa[ans[i]]; return ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:34:19: 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<ans1.size(); i++)
      |                  ~^~~~~~~~~~~~
perm.cpp:39:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (ll i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
perm.cpp:41:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (ll i=0; i<ans.size(); i++)
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...