답안 #250285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250285 2020-07-17T10:39:35 Z Pbezz Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
10000 ms 6548 KB
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for (ll i = 0; i < n; i++)

#define ll long long
#define INF 1e9+5
#define MAXN 300007
#define pb push_back 
#define mp make_pair
typedef pair<ll,ll> pii;




int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	ll t,n;

	cin>>t;
	while(t--){

	string s,mleft, mright;
	cin>>s;
	n=(ll)s.size();

	ll i=0,j=n-1,left=0,right=n-1,ans=1;


	while(i<j){

	mleft=s.substr(left,i-left+1);//de left a i
	mright=s.substr(j,right-j+1);//de j a right

	if(mleft==mright){ 

	left=i+1; right=j-1;
	ans+=2;
	if(i==j-1)ans--;

	}
	i++; j--;


	}

	cout<<ans<<'\n'; 





}

return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 10 ms 512 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 10 ms 512 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Execution timed out 10010 ms 6548 KB Time limit exceeded
15 Halted 0 ms 0 KB -