제출 #605421

#제출 시각아이디문제언어결과실행 시간메모리
605421AugustinasJucas순열 (APIO22_perm)C++17
10 / 100
1 ms304 KiB
#include "perm.h" #include <bits/stdc++.h>\ using namespace std; vector<int> construct_permutation(long long k) { vector<int> init; int ind = 0; int liko = 0; for(int i = 0; i < 64; i++) { long long bus = (1 << i); if(bus > k) { // desim i-1 tu. for(int j = 0; j < i-1; j++) init.push_back(ind++); liko = k - (1 << (i-1)); break; } } // cout << "liko = " << liko << ", popcnt = " << __builtin_popcount(liko) << endl; vector<int> ret; ind += __builtin_popcountll(liko) - 1; for(int i = 0; i < init.size(); i++) { if((1 << i) & liko) { ret.push_back(ind); ind--; } ret.push_back(init[i]); } // cout << "ret = "; for(auto x : ret) cout << x << " "; //cout << endl; return ret; }

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

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