답안 #638480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638480 2022-09-06T08:56:29 Z minhnhatnoe 순열 (APIO22_perm) C++17
10 / 100
1 ms 212 KB
#include "perm.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<int> construct_permutation(long long k){
    deque<float> a;
    int val = 31 - __builtin_clz(k);
    for (int i=0; i<val; i++){
        a.push_back(i+1);
    }
    for (int i=val-1; i>=0; i--){
        if ((k & (1<<i)) == 0) continue;
        a.push_front(a[a.size() - i - 1] + 0.5);
    }
    // for (int i=0; i<a.size(); i++){
    //     cout << a[i] << " ";
    // }
    // cout << "\n";
    deque<float> b = a;
    sort(b.begin(), b.end());
    vector<int> result(a.size());
    for (int i=0; i<a.size(); i++){
        result[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() ;
        // cout << result[i] << " ";
    }
    // cout << endl;
    return result;
}
// signed main(){
//     construct_permutation(0b11);
// }

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<float>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i=0; i<a.size(); i++){
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -