General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
114534653 Practice:
k4droid3
1509E - 10 C++17 (GCC 9-64) Accepted 30 ms 400 KB 2021-04-29 16:05:44 2021-04-29 16:05:45
→ Source
#include <iostream>
#include <algorithm>

#define rep(i,e) for(int i = 0; i < e; i++)
#define reps(i,s,e) for(ll i = s; i <= e; i++)
#define rev(i,s) for(ll i = s; ~i; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ff first
#define ss second

using namespace std;
typedef long long ll;
const ll MOD=1000000007;

void solve(){
    ll n, k;
    cin >> n >> k;

    if(n <= 60 and k > (1ll<<(n-1))){
        cout << -1 << '\n';
        return;
    }
    k--;

    int arr[n];
    rep(i, n) arr[i] = n-i;
    
    int l=0, r=0;
    // cout << __lg(k) + 1 << '\n';
    while(r <= __lg(k)){
        if(k&(1ll<<r))r++;
        else{
            sort(arr+1+l-1, arr+r+1);
            r++; l=r;
        }
        // cout << l << ' ' << r << ": ";
        // rep(i, n) cout << arr[i] << ' ';
    }
    if(l != r) sort(arr+1+l-1, arr+r+1);

    rev(i, n-1) cout << arr[i] << ' '; cout << '\n';
}

int main(){
#ifdef k4droid3
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--)
        solve();
    
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details