Submission #731433

#TimeUsernameProblemLanguageResultExecution timeMemory
731433ogibogi2004Permutation (APIO22_perm)C++17
71.22 / 100
13 ms1332 KiB
#include "perm.h" #include<bits/stdc++.h> #define ll long long using namespace std; vector<int> construct_permutation(long long k) { vector<int>ret; int sz=0; k--; while(k) { ll p=0; while((1ll<<p)-1<=k) { p++; } p--; ret.push_back(p); k-=(1ll<<p)-1; } for(int i=0;i<ret.size();i++)sz+=ret[i]; vector<int>ans; for(int i=0;i<ret.size();i++) { for(int j=1;j<=ret[i];j++) { ans.push_back(sz-ret[i]+j); } sz-=ret[i]; } for(int i=0;i<ans.size();i++)ans[i]--; //for(auto xd:ans)cout<<xd<<" "; //cout<<endl; return ans; }

Compilation message (stderr)

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