Submission #645767

#TimeUsernameProblemLanguageResultExecution timeMemory
645767rodovBrperm (RMI20_brperm)C++14
13 / 100
2 ms1364 KiB
#include "brperm.h"
/////////

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll DIM = 1E3+7;
ll A[DIM],nn;
ll gi(char ch){
    return (ch-'a'+1);
}
void init(int n, const char s[]) {
    nn = n;
    for(ll i = 1;i<=n;++i){
        A[i] = gi(s[i-1]);
    }
    return;
}

int query(int i, int k) {
    ll l = i+1,r = i+(1ll<<k);
    if (r>nn || l<0)return 0;
    for(ll i = l;i<=r;++i){
        vector<ll> bit;
        ll x = i-l;
        for(ll j = 1;j<=k;++j){
            bit.push_back(x&1);
            x/=2;
        }
        //reverse(bit.begin(),bit.end());
        x = 0;
        for(ll to:bit){
            x*=2;
            x+=to;
        }
        if (A[x+l]!=A[i])return 0;
    }

    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...