Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
484 B
6
Indexable
Never
#include <iostream>
#include <cmath>
#define int long long
using namespace std;

signed main () {
    int t; cin>>t;
    while (t--) {
        int n; cin>>n;
        int arr[n];
        bool f = true;
        for (int i=0; i<n; i++) cin>>arr[i];
        for (int i=0; i<n-1; i++) {
            if (arr[i]>arr[i+1]) {
                if (ceil(log2(i+1)) != floor(log2(i+1))) {f = false; break;}
            }
        }
        if (f) cout << "YES\n";
        else cout<<"NO\n";
    }
}