Submission #1086947

# Submission time Handle Problem Language Result Execution time Memory
1086947 2024-09-11T19:47:52 Z ZeroCool Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
14 ms 12552 KB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define int long long
#define ld long double
#define crash assert(69 == 420)

const int MOD = 1e9 + 7;
const int INF = 1e17;
const int N = 2e5  + 20;
const int LOG = 20;

const int B = 954285419; //! Pray to RNGesus for no collisions

int pw[N];

signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
	int t;
	cin>>t;
	pw[0] = 1;
	for(int i = 1;i < N;i++)pw[i] = (pw[i - 1] * B) % MOD;
	while(t--){
		string s;
		cin>>s;
		int n = s.size();
		int ans = 0;
		int l = 0, r = n - 1;
		int x = 0, y = 0, sz = 0;
		while(l < r){
			x = (x * B + s[l] ) % MOD;
			y = (y + pw[sz] * s[r] ) % MOD;
			if(x == y){
				x = y = sz = 0;
				ans += 2;
			}else sz++;
			l++, r--;
		}
		if(n % 2 || sz)ans++;
		cout<<ans<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1884 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1884 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 2140 KB Output is correct
11 Correct 2 ms 1884 KB Output is correct
12 Correct 2 ms 2140 KB Output is correct
13 Correct 2 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1884 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 2140 KB Output is correct
11 Correct 2 ms 1884 KB Output is correct
12 Correct 2 ms 2140 KB Output is correct
13 Correct 2 ms 2132 KB Output is correct
14 Runtime error 14 ms 12552 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -