Submission #911280

# Submission time Handle Problem Language Result Execution time Memory
911280 2024-01-18T17:41:20 Z LuciferGoku Permutation (APIO22_perm) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
#define int long long

// signed main(){
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     int t;
//     cin >> t;
//     while(t--){
//         int x;
//         cin >> x;
//         vector<int> ans;
//         int j=0;
//         while((1LL<<j)<=x) j++;
//         j--;
//         for(int i=1; i<=j; i++) ans.push_back(i);
//         x-=(1LL<<j);
//         // cout << x << endl;
//         while(x!=0){
//             j=0;
//             while((1LL<<j)<=x) j++;
//             ans.push_back(j);
//             j--;
//             x-=(1LL<<j);
//         }
//         cout << ans.size() << endl;
//         for(auto i: ans){
//             cout << i << " ";
//         }
//         cout << endl;
//     }
//     return 0;
// }

vector<int> construct_permutation(ll k){
    int x=k;
    vector<int> ans;
    int j=0;
    while((1LL<<j)<=x) j++;
    j--;
    for(int i=1; i<=j; i++) ans.push_back(i-1);
    x-=(1LL<<j);
    while(x!=0){
        j=0;
        while((1LL<<j)<=x) j++;
        ans.push_back(j-1);
        j--;
        x-=(1LL<<j);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -