# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
205388 | dolphingarlic | Palindromic Partitions (CEOI17_palindromic) | C++14 | 50 ms | 20784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
컴파일 시 표준 에러 (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... |