# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205388 | dolphingarlic | Palindromic Partitions (CEOI17_palindromic) | C++14 | 50 ms | 20784 KiB |
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>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef unsigned long long ll;
using namespace std;
const ll P = 29;
ll pw[1000001]{1};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
FOR(i, 1, 1000001) pw[i] = pw[i - 1] * P;
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
int l = 0, r = s.size() - 1, pl = 0, pr = s.size() - 1;
int ans = 0;
ll hsh_l = 0, hsh_r = 0;
while (l < r) {
hsh_l = hsh_l * P + (s[l++] - 'a' + 1);
hsh_r += pw[pr - r] * (s[r--] - 'a' + 1);
if (hsh_l == hsh_r) {
FOR(i, 0, l - pl) if (s[pl + i] != s[r + i]) continue;
ans += 2;
hsh_l = hsh_r = 0;
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... |