답안 #699855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699855 2023-02-18T07:18:34 Z sharaelong 순열 (APIO22_perm) C++17
91.3333 / 100
2 ms 340 KB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> construct_permutation(ll k) {
	int pow = 0;
    while ((1ll << pow) <= k) pow++;
    pow--;
    
    int cnt = pow;
    vector<int> arr(pow, -1);
    for (int i=pow-1; i>=0; --i) {
        if (k & (1ll << i)) {
            arr[i] = pow++;
        }
    }

    vector<int> ret;
    for (int i=0; i<arr.size(); ++i) {
        if (arr[i] != -1) ret.push_back(arr[i]);
        ret.push_back(i);
    }
    return ret;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i=0; i<arr.size(); ++i) {
      |                   ~^~~~~~~~~~~
perm.cpp:12:9: warning: unused variable 'cnt' [-Wunused-variable]
   12 |     int cnt = pow;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Partially correct 1 ms 300 KB Partially correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Partially correct 1 ms 340 KB Partially correct
9 Correct 1 ms 340 KB Output is correct
10 Partially correct 2 ms 300 KB Partially correct
11 Partially correct 2 ms 340 KB Partially correct
12 Partially correct 2 ms 340 KB Partially correct
13 Partially correct 2 ms 296 KB Partially correct