제출 #1041349

#제출 시각아이디문제언어결과실행 시간메모리
1041349MarwenElarbi순열 (APIO22_perm)C++17
91.33 / 100
1 ms440 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; #define pb push_back std::vector<int> construct_permutation(long long k) { k--; vector<int> tab; int cnt=0; int mx=0; for (int i = 62; i > 0; --i) { while(mx==0&&k>=(1LL<<i)-1){ mx=i; k-=(1LL<<i)-1; tab.pb(i); } while(mx>0&&k>=(1LL<<(i-1))){ k-=(1LL<<(i-1)); tab.pb(i); } } sort(tab.rbegin(),tab.rend()); vector<int> ans; int j=1; for (int i = 0; i < mx;++i) { ans.pb(tab.size()+i-1); while(j<tab.size()&&mx-i==tab[j]){ ans.pb(tab.size()-j-1); j++; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:29:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   while(j<tab.size()&&mx-i==tab[j]){
      |         ~^~~~~~~~~~~
perm.cpp:9:6: warning: unused variable 'cnt' [-Wunused-variable]
    9 |  int cnt=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...