# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
622671 | enter_hedgehog_poly | Palindromic Partitions (CEOI17_palindromic) | C++11 | 57 ms | 11008 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Palindromiczny podział
#include <bits/stdc++.h>
using namespace std;
char buff[1000010];
typedef uint64_t ll;
const ll P = 31;
const ll MOD_N = 31;
const ll MOD = ((ll) 1 << MOD_N) - 1;
inline ll FMOD(ll x) { return ((x) >> MOD_N) + ((x) & MOD); }
int main() {
int t;
scanf("%d", &t);
while(t--) {
scanf("%s", buff + 1);
int n = strlen(buff + 1);
ll left = 0, right = 0, exp = 1;
int lp = 1, res = 0;
for(int i = 1; i <= n / 2; i++) {
left = FMOD(left + (buff[i] - 'a' + 1) * exp);
exp = FMOD(exp * P);
right = FMOD(right * P + (buff[n + 1 - i] - 'a' + 1));
if(left == right) {
exp = 1;
left = right = 0;
res += 2;
lp = i + 1;
}
}
if(lp != (n / 2) + 1 || (n & 1)) res++;
printf("%d\n", res);
}
return 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... |