# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
536471 | Asymmetry | Palindromic Partitions (CEOI17_palindromic) | C++17 | 174 ms | 18804 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif
const int N = 1'000'100;
const int MOD = 1e9 + 7;
const int P = 29;
int n;
int hs[N];
int pot[N];
char s[N];
long long has(int a, int b) {
return (hs[b] - (long long)hs[a - 1] * pot[b - a + 1] % MOD + MOD) % MOD;
}
void solve() {
scanf("%s", s + 1);
n = strlen(s + 1);
pot[0] = 1;
for (int i = 1; i <= n; ++i) {
hs[i] = ((long long)hs[i - 1] * P + s[i] - 'a' + 1) % MOD;
pot[i] = (long long)pot[i - 1] * P % MOD;
}
int odp = 0;
int ost = 1;
for (int i = 1; i <= n / 2; ++i) {
if (has(ost, i) == has(n - i + 1, n - ost + 1)) {
odp += 2;
ost = i + 1;
}
}
if (n & 1 || (!(n & 1) && ost <= n / 2)) {
++odp;
}
printf("%d\n", odp);
}
int main() {
int q=1;
scanf("%d", &q);
while(q--) {
solve();
}
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... |