답안 #670381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670381 2022-12-08T19:59:53 Z Mohammad_Parsa Palindromic Partitions (CEOI17_palindromic) C++17
100 / 100
56 ms 11780 KB
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

//#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mk make_pair
typedef long long ll;

const ll N=1e6+7,mod=1e13+3,mab=27;

int main(){
	ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while(q--){
		string s;
		cin>>s;
		ll h1=0,h2=0,t=1;
		int j=s.size()-1,sz=s.size();
		int ans=0;
		for(int h=0;h<=sz/2-1;h++){
			//cout<<sz/2-1<<endl;
			h1=h1*mab%mod;h1=(h1+s[h]-'a'+1)%mod;
			h2=(h2+(s[j-h]-'a'+1)*t)%mod;t=t*mab%mod;
			if(h1==h2){
				ans+=2;
				t=1;h1=0;h2=0;
			}
		}
		if(h1!=0 || s.size()%2==1)ans++;

		cout<<ans<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 51 ms 6168 KB Output is correct
15 Correct 29 ms 7700 KB Output is correct
16 Correct 56 ms 11780 KB Output is correct
17 Correct 25 ms 6916 KB Output is correct