답안 #226676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226676 2020-04-24T18:11:44 Z keta_tsimakuridze Palindromic Partitions (CEOI17_palindromic) C++14
0 / 100
14 ms 8320 KB
#include<bits/stdc++.h>
using namespace std;
long long mod,p,t,k,i,pwr[1000005],j,s1,s2,cur,ans;
string s;
int main(){
	cin>>t;
	p=31;
	mod=1e9+7;
	pwr[1]=1;
	for(k=2;k<=1000005;k++){
		pwr[k]=pwr[k-1]*p%mod;
	}
	while(t--){
		cin>>s;
		j=s.size()-1;
        cur=1;
		for(i=0;i<(s.size())/2;i++){
			s1+=pwr[cur]*((int)s[i]-'a'+1);
			s1%=mod;
			s2=s2*p%mod+((int)s[j]-'a'+1);
			s2%=mod;  
			if(s1==s2){
				cur=1; s1=s2=0; 
				ans+=2; 
			}else cur++;
			j--;
		} s2=s1=0;
		if(cur!=1 || s.size()%2==1) cout<<ans+1<<endl;
		else cout<<ans;
		ans=0;
	}
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:17:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<(s.size())/2;i++){
           ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -