# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869247 | LOLOLO | Palindromic Partitions (CEOI17_palindromic) | C++14 | 67 ms | 28440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int BASE = 37;
long long haha[N];
long long hihi[N];
long long kkk(int L, int R)
{
return haha[R] - haha[L - 1] * hihi[R - L + 1];
}
void solve()
{
string s;
cin >> s;
int n = s.size();
s = ' ' + s;
for (int i = 1; i <= n; i++)
haha[i] = haha[i - 1] * BASE + s[i] - 'a' + 1;
int l = 1, r = n;
int ahihi = 1, orz = n;
long long hjhj, hehe;
int ans = 0;
while (l < r)
{
hjhj = kkk(ahihi, l);
hehe = kkk(r, orz);
if (hjhj == hehe)
{
ahihi = l + 1,
orz = r - 1;
ans += 2;
hjhj = 0, hehe = 0;
}
l++;
r--;
}
cout << ans + (l == r || hjhj != hehe) << "\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
hihi[0] = 1;
for (int i = 1; i < N; i++)
hihi[i] = hihi[i - 1] * BASE;
int t;
cin >> t;
while (t--)
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... |