답안 #572914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572914 2022-06-05T13:31:42 Z moday_morning 순열 (APIO22_perm) C++17
0 / 100
1 ms 340 KB
#include "perm.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

vector<int> construct_permutation(ll k)
{
    // 90 balls
    vector <int> ans;
    vector <int> bytes;
    for (int i = 63; i >= 0; i--) {
        if (k & (1ll << i) != 0) {
            bytes.push_back(i);
        }
    }
    int mx = bytes[0];
    for (int i = 0; i < mx; i++) {
        ans.push_back(i);
    }
    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]++;
            }
        }
    }
    return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:12:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   12 |         if (k & (1ll << i) != 0) {
      |                 ~~~~~~~~~~~^~~~
perm.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 1; i < bytes.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
perm.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < ans.size(); j++) {
      |                         ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -