# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
478270 |
2021-10-06T19:01:51 Z |
stefantaga |
Brperm (RMI20_brperm) |
C++14 |
|
287 ms |
168848 KB |
#include "brperm.h"
#include <cstring>
#include <bits/stdc++.h>
#define baza 31
#define MOD 1000000007
using namespace std;
int invers[500005][21];
int hash1[500005][21];
char v[500005];
int put[25];
void init(int n, const char s[]) {
int i,j;
put[0]=baza;
for (i=1;i<=19;i++)
{
put[i]=(1LL*put[i-1]*put[i-1])%MOD;
}
for (i=0;i<n;i++)
{
invers[i][0]=s[i]-'a';
}
for (int i=1;i<=19;i++)
{
for (j=0;j+(1<<i)-1<n;j++)
{
invers[j][i]=(invers[j][i-1]+(1LL*invers[j+(1<<(i-1))][i-1]*put[19-i])%MOD)%MOD;
}
}
for (i=0;i<=19;i++)
{
for (j=n-1;j>=0;j--)
{
hash1[j][i]=((s[j]-'a')+1LL*hash1[j+1][i]*put[19-i])%MOD;
}
}
}
int query(int i, int k) {
int ceau1=(hash1[i][k]-(1LL*hash1[i+(1<<k)][k]*put[19])%MOD+MOD)%MOD;
int ceau2=invers[i][k];
return ceau1==ceau2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
80 ms |
17124 KB |
Output is correct |
4 |
Correct |
75 ms |
17028 KB |
Output is correct |
5 |
Correct |
74 ms |
17060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
287 ms |
168848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
80 ms |
17124 KB |
Output is correct |
4 |
Correct |
75 ms |
17028 KB |
Output is correct |
5 |
Correct |
74 ms |
17060 KB |
Output is correct |
6 |
Runtime error |
287 ms |
168848 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |