제출 #670375

#제출 시각아이디문제언어결과실행 시간메모리
670375Mohammad_ParsaPalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
0 ms212 KiB
/* 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;
		int ans=0;
		for(int h=0;h<=s.size()/2-1;h++){
			h1=h1*mab%mod;h1=(h1+s[h]-'a')%mod;
			h2=(h2+(s[j-h]-'a')*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;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

palindromic.cpp: In function 'int main()':
palindromic.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int h=0;h<=s.size()/2-1;h++){
      |               ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...