답안 #128094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128094 2019-07-10T12:13:16 Z faustaadp Palindromic Partitions (CEOI17_palindromic) C++17
100 / 100
77 ms 10640 KB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
string s,s1,s2;
ll n,i,has,t;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		has=0;
		cin>>s;
		ll las1=0,las2=n-1;
		n=s.length();
		ll K1=27,P1=1,mo=1e9+7;
		ll A=0,B=0;
		for(i=0;i<n;i++)
		{
			if(i>=(n-i-1))break;
			A=(A*K1)%mo;
			A=(A+(s[i]-'a'))%mo;
			B=(B+((s[n-i-1]-'a')*P1)%mo)%mo;
			P1=(P1*K1)%mo;
			if(A==B)
			{
				las1=i;
				las2=n-i-1;
				las1++;
				las2--;
				has+=2;
				P1=1;
				A=0;
				B=0;
			}
		}
		if(las1<=las2)has++;
		cout<<has<<"\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 77 ms 8020 KB Output is correct
15 Correct 53 ms 6676 KB Output is correct
16 Correct 73 ms 10640 KB Output is correct
17 Correct 39 ms 6036 KB Output is correct