Submission #638480

# Submission time Handle Problem Language Result Execution time Memory
638480 2022-09-06T08:56:29 Z minhnhatnoe Permutation (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++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 -