답안 #1094548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094548 2024-09-29T22:17:03 Z raphaelp Palindromic Partitions (CEOI17_palindromic) C++14
35 / 100
2 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        string S;
        cin >> S;
        int N = S.size() / 2;
        long long cur1 = 0, cur2 = 0;
        long long a = 832991340, b = 934618349, mult = 1;
        int last = -1;
        int nb = 0;
        for (int i = 0; i < N; i++)
        {
            cur1 = (cur1 * a + S[i]) % b;
            cur2 = (cur2 + mult * S[S.size() - i - 1]) % b;
            mult = (mult * a) % b;
            if (cur1 == cur2)
            {
                last = i;
                cur1 = 0, cur2 = 0, mult = 1;
                nb += 2;
            }
        }
        if (S.size() % 2 || last < N - 1)
            nb++;
        cout << nb << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Incorrect 1 ms 344 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Incorrect 1 ms 344 KB Output isn't correct
12 Halted 0 ms 0 KB -