QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#520131#148. Brperm369Pai0 0ms0kbC++201.3kb2024-08-15 11:00:362024-08-15 11:00:36

Judging History

你现在查看的是最新测评结果

  • [2024-08-15 11:00:36]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-08-15 11:00:36]
  • 提交

answer

#include "brperm.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 5e5 + 5 , LG = 20 , P = 131;
int t; ull p[LG] = {P} , f[LG][N] , h[LG][N] , pp[LG][N] , iv[LG][N];
ull Qpow(ull x , ull p = (1llu << 63) - 1)
{
  ull res = 1;
  for(; p ; p >>= 1 , x = x * x)
    if(p & 1)res = x * res;
  return res;
}
ull Get(int k , int l , int r){return (h[k][r] - h[k][l - 1]) * iv[t - k][l - 1];}
void init(int n, const char s[]) {

  t = __lg(n);
  for(int i = 1 ; i <= t ; i++)
    p[i] = p[i - 1] * p[i - 1];
  for(int i = 0 ; i <= t ; i++)
  {
    pp[i][0] = iv[i][0] = 1;
    for(int j = 1 ; j <= n ; j++)
      pp[i][j] = pp[i][j - 1] * p[i];   
    iv[i][1] = Qpow(p[i]);
    for(int j = 2 ; j <= n ; j++)
      iv[i][j] = iv[i][j - 1] * iv[i][1];
  }
  for(int i = 1 ; i <= n ; i++)f[0][i] = s[i - 1];
  for(int i = 1 ; i <= t ; i++)
    for(int j = 1 ; j + (1 << i) - 1 <= n ; j++)
      f[i][j] = f[i - 1][j] + p[t - i] * f[i - 1][j + (1 << (i - 1))];

  for(int i = 0 ; i <= t ; i++)
    for(int j = 1 ; j <= n ; j++)
      h[i][j] = h[i][j - 1] + s[j - 1] * pp[t - i][j - 1];
  return;
}
int query(int l, int k) 
{
  int r = (++l) + (1 << k) - 1;
  return f[k][l] == Get(k , l , r);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

ykkubxafnylfriivjjqphltuagfkfcoigfcukuisdgufezomndodalbusgesraatkgnskdsiedfysodmsemmtjuoiezoaqljdodegogedjfpfwntljpgdhswtmqtwtpnbaawfumskuiwjodtsrlhblpunzqjkrzaakamjzyumkzfdjxwdkadgbwffjmldsfbhaltfnykbmvnxdkpfzsswpnmyyqpalsalaeqmqqivzqyhjgiiwfugmpxxsmkkgecuvrnlkujbyllhecpjsneluvsyckueeexhbtuhikfzuvw...

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Memory Limit Exceeded

Test #6:

score: 0
Memory Limit Exceeded

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%