Submission #975997

# Submission time Handle Problem Language Result Execution time Memory
975997 2024-05-06T04:51:10 Z Orifkhon Permutation (APIO22_perm) C++17
10 / 100
1000 ms 1468 KB
#include<bits/stdc++.h>
#include "perm.h"

using namespace std;
#ifdef LOCAL
#include "debug.cpp"
#else
#define debug(...) 
#endif


vector<int> construct_permutation(long long k) {
    int size = log2(k);

    vector<int> perm(size);
    for(int i = 0; i < size; i++){
        perm[i] = i;
    }	
    k-=(1 << size);
    int insert = size;
    while(true){
        if(k == 0){
            break;
        }
        int ind = log2(k);
        k-=(1 << ind);
        if(ind == 0){
            perm.insert(perm.begin(), insert);
            insert++;
            continue;
        }
        perm.insert(perm.begin() + ind, insert);
        insert++;
    }
    debug(perm);
    return perm;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1096 ms 1468 KB Time limit exceeded
6 Halted 0 ms 0 KB -