Submission #635909

#TimeUsernameProblemLanguageResultExecution timeMemory
635909Minindu2006Permutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define ll long long vector<int> ind(ll k) { vector<int> v; while(k > 0) { v.push_back(k % 2); k /= 2; } vector<int> ans; for(int i=0;i<v.size();i++) { if(v[i]) ans.push_back(i); } return ans; } std::vector<int> construct_permutation(long long k) { vector<int> cur = ind(k), ans; int n = cur.size(); for(int i=0;i<cur[n - 1];i++) ans.push_back(i); if(n == 1) return ans; cur.pop_back(); reverse(cur.begin(), cur.end()); int nxt = cur[n - 1]; for(int i=0;i<n - 1;i++) { ans.insert(ans.begin() + cur[i], nxt); nxt++; } return ans; }

Compilation message (stderr)

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