제출 #1156608

#제출 시각아이디문제언어결과실행 시간메모리
1156608sodbayrPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h>
#include <string>
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define mod 1000000007
#define endl "\n"
using namespace std;
	ll n,t,k,m,a;
	string s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
	while(t--){
		cin>>s;ll sum=1,p=0;
		n=s.size();
		ll o=n,i=1,j=0;
		hash<string> hs,sh;
		for(ll j=0;j<n/2;j++){
			ll q=hs(s.substr(p,i));
			ll e=sh(s.substr(o-i,i));
			//cout<<p<<' '<<o<<' ';
			if(q==e){
				sum+=2;
				p+=i;o-=i;i=0;
			}
			i++;
		}
		cout<<sum<<endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...