| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1338234 | cowwycow | Brperm (RMI20_brperm) | C++20 | 343 ms | 213244 KiB |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "brperm.h"
using namespace std;
#define name "aaaaaa"
#define endl "\n"
#define fi first
#define se second
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdb = pair<db, db>;
using ppii = pair<ll, pii>;
using ull = unsigned long long;
using vvi = vector<vector<int>>;
void file(){
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
}
const int N = 5e5 + 5;
const int L = 20;
const int B = 31;
const ll mod = 1e9 + 7;
int n;
char c[N];
ll sus[L];
ll hsh[L][N], b[L][N];
ll hsh2[L][N];
void init(int N, const char S[]){
n = N;
for(int i = 0; i < n; i++){
c[i] = S[i];
}
sus[0] = 1;
sus[1] = B;
for(int i = 2; i < L; i++){
sus[i] = sus[i - 1] * sus[i - 1] % mod;
}
for(int i = 0; i < n; i++){
hsh2[0][i] = c[i] - 'a' + 1;
}
for(int i = 1; (1 << i) <= n; i++){
for(int j = 0; j + (1 << i) <= n; j++){
hsh2[i][j] = (hsh2[i - 1][j] * sus[1 << (i - 1)] + hsh2[i - 1][j + (1 << (i - 1))]) % mod;
}
}
for(int i = 0; (1 << i) <= n; i++){
for(int j = 0; j < n; j++){
b[0][j] = c[j] - 'a' + 1;
}
for(int j = 1; j <= i; j++){
for(int k = 0; k + (1 << j) <= n; k++){
b[j][k] = (b[j - 1][k] * sus[1 << (j - 1)] + b[j - 1][k + (1 << (i - j))]) % mod;
}
}
for(int j = 0; j + (1 << i) <= n; j++){
hsh[i][j] = b[i][j];
}
}
}
int query(int i, int k){
return hsh[k][i] == hsh2[k][i];
}Compilation message (stderr)
| # | 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... | ||||
