Submission #644799

#TimeUsernameProblemLanguageResultExecution timeMemory
644799Tenis0206Permutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; int fr[100005]; vector<int> construct_permutation(long long k) { int nr = 0; long long aux = k; while(aux!=1) { ++nr; aux /= 2; } vector<int> suf; for(int b=0;b<nr;b++) { if((k & (1LL<<b)) != 0) { suf.push_back(b + suf.size()); } } reverse(suf.begin(),suf.end()); for(auto it : suf) { ++fr[it]; } int cnt = 0; vector<int> rez; for(int i=1;i<=nr;i++) { while(fr[cnt]) { ++cnt; } rez.push_back(cnt); ++cnt; } for(auto it : suf) { rez.push_back(it); } for(int i=0;i<rez.size();i++) { fr[i] = 0; } return rez; }

Compilation message (stderr)

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