Submission #717748

#TimeUsernameProblemLanguageResultExecution timeMemory
717748125259Permutation (APIO22_perm)C++17
64.62 / 100
18 ms1492 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<long long>num; void start(){ long long cnt=1; for(int i=0; i<63; i++){ num.push_back(cnt); cnt*=2; } return; } vector<int> construct_permutation(long long k){ start(); vector<int>v; k--; for(int i=62; i>=0; i--){ if(k>=num[i]){ v.push_back(i); k-=num[i]; } } deque<int>d; int cnt=-1; for(int i=0; i<v.size(); i++){ cnt+=v[i]; for(int j=0; j<v[i]; j++){ d.push_front(cnt); cnt--; } cnt+=v[i]; } cnt++; for(int i=0; i<v.size(); i++) { d.push_front(cnt); cnt++; } v.clear(); for(int i=0; i<d.size(); i++)v.push_back(d[i]); return v; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0; i<v.size(); i++){
      |               ~^~~~~~~~~
perm.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i=0; i<v.size(); i++) {
      |               ~^~~~~~~~~
perm.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0; i<d.size(); i++)v.push_back(d[i]);
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...