Submission #733646

# Submission time Handle Problem Language Result Execution time Memory
733646 2023-05-01T06:34:54 Z Erkinoff_Mohammed Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 340 KB
#include "perm.h"
#include "bits/stdc++.h"
using namespace std;
#define INF 2000000000
#define INFLL 3000000000000000000LL
#define ll long long

vector<int> construct_permutation(long long k){
    vector<int>l;
    while(k>0){
        long long n=1;
        int cnt=0;
        while(n*2<=k){
            n<<=1;
            cnt++;
        }
        l.push_back(cnt);
        k-=n;
    }
    vector<int>vec(l[0]+l.size()-1);
    for(int i=0;i<l[0]+l.size()-1;i++){
        vec[i]=i;
    }
    vector<int>en;
    for(int i=l.size()-1;i>0;i--){
        en.push_back(vec[l[i]]);
        vec.erase(find(vec.begin(), vec.end(), vec[l[i]]));
    }
    for(int i=en.size()-1;i>-1;i--){
        vec.push_back(en[i]);
    }
    
	return vec;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:21:18: 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<l[0]+l.size()-1;i++){
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 340 KB Partially correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Partially correct 2 ms 340 KB Partially correct
9 Correct 1 ms 300 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 340 KB Partially correct