This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "brperm.h"
using namespace std;
const int maxn = 5e5+3;
char c[maxn];
int st[100],i,j,p,q,N,m,k,l,opposite[maxn],pos[maxn];
void precompute(int l)
{
st[0] = 1;
for(i=1;i<=l;i++)
st[i] = st[i-1]*2;
}
void init (int n,const char s[])
{
N = n;
for(i=0;i<n;i++)
c[i] = s[i];
l = 1;
while((1<<l)<=n)
l++;
precompute(l);
k = 1;
for(i=0;i<n;i++)
{
if((1<<k)<=i)
k++;
int opp = 0;
for(j=0;(1<<j)<=i;j++)
{
if(((1<<j)&i))
opp|=(1<<(k-j-1));
}
opposite[i] = opp;
pos[i] = k;
}
}
int query(int i,int k)
{
for(j=i;j<i+st[k];j++)
{
q = j-i;
p = opposite[q]*st[k-pos[q]];
if(c[p+i]!=c[j])
return 0;
}
return 1;
}
/**
int main()
{
init(8,"axxyxxyb");
cout<<query(0, 2);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |