제출 #572922

#제출 시각아이디문제언어결과실행 시간메모리
572922moday_morning순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> construct_permutation(long long k)
{
    // 90 balls
    vector <int> ans;
    vector <int> bytes;
    for (int i = 63; i >= 1; i--) {
        if (k & (1ll << i)) {
            bytes.push_back(i);
        }
    }
    int mx = bytes[0];
    for (int i = 0; i < mx; i++) {
        ans.push_back(i);
    }
    
//    cout << "bytes" << endl;
//    for (int el : bytes) {
//        cout << el << " ";
//    }cout << endl;
//
    for (int i = 1; i < bytes.size(); i++) {
        int cur_bit = bytes[i];
        for (int j = 0; j < ans.size(); j++) {
            if (ans[j] >= cur_bit) {
                ans[j]++;
            }
        }
        ans.push_back(cur_bit);
    }
    if (k % 2) {
        for (int j = 0; j < ans.size(); j++) {
            ans[j]++;
        }
        ans.push_back(0);
    }
    return ans;
}

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

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