Submission #821347

#TimeUsernameProblemLanguageResultExecution timeMemory
821347HanksburgerPermutation (APIO22_perm)C++17
82.05 / 100
6 ms736 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { if (k&1) { for (long long i=2, m=1; ; i*=2, m++) { if (i<k && i*2>k) { vector<int> res=construct_permutation(k-i+1); for (long long j=0; j<res.size(); j++) res[j]+=m; for (long long j=0; j<m; j++) res.push_back(j); return res; } } } long long cnt=0; while (k%2==0) { k/=2; cnt++; } if (k==1) { vector<int> res; for (long long i=0; i<cnt; i++) res.push_back(i); return res; } vector<int> res=construct_permutation(k); int sz=res.size(); for (long long j=0; j<cnt; j++) res.push_back(j+sz); return res; }

Compilation message (stderr)

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