# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
519475 |
2022-01-26T12:15:34 Z |
Stickfish |
Brperm (RMI20_brperm) |
C++17 |
|
3000 ms |
10160 KB |
#include "brperm.h"
#include <string>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int MAXN = 500008;
const ll MOD = 1000000007;
const ll MUL = 27;
string s;
ll phash_[MAXN];
ll* phash = phash_ + 1;
ll pw(ll a, ll m) {
if (!m)
return 1;
a %= MOD;
if (m % 2)
return (a * pw(a, m - 1)) % MOD;
return pw(a * a, m / 2);
}
const ll RMUL = pw(MUL, MOD - 2);
ll get_hash(int l, int r) {
return (MOD + phash[r - 1] - pw(phash[l - 1], MOD - 2)) % MOD * pw(RMUL, l) % MOD;
}
void init(int n, const char s_[]) {
for (int i = 0; i < n; ++i)
s.push_back(s_[i]);
ll raymoo = 1;
for (int i = 0; i < n; ++i) {
phash[i] = (phash[i - 1] + raymoo * (s[i] - 'a')) % MOD;
raymoo = (raymoo * MUL) % MOD;
//cout << phash[i] << ' ';
}
cout << endl;
return;
}
int query(int l, int k) {
vector<int> ps = {0};
for (int t = 0; t < k; ++t) {
for (int i = 0; i < (1 << t); ++i)
ps.push_back(ps[i] + (1 << (k - t - 1)));
}
for (int i = 0; i < (1 << k); ++i) {
if (s[l + i] != s[l + ps[i]])
return 0;
}
return 1;
for (auto x : ps)
cout << x << ' ';
cout << "$ ";
ll ans = 0;
ll pw = 1;
for (int i = 0; i < (1 << k); ++i) {
cout << s[ps[i] + l];
ans = (ans + pw * (s[ps[i] + l] - 'a')) % MOD;
pw = (pw * MUL) % MOD;
}
cout << " | ";
ll ans0 = 0;
pw = 1;
for (int i = 0; i < (1 << k); ++i) {
cout << s[i + l];
ans0 = (ans0 + pw * (s[i + l] - 'a')) % MOD;
pw = (pw * MUL) % MOD;
}
cout << ": ";
cout << ans0 << ' ' << get_hash(l, l + (1 << k)) << ' ';
return ans == get_hash(l, l + (1 << k));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
4920 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
4920 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3027 ms |
10160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
4920 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |