| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1322723 | Johan | Palindromic Partitions (CEOI17_palindromic) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--){
string s;
cin >> s;
int cnt = 0, n = (int)s.size(), lst = 0;
s = '#' + s;
for(int i = 1; i <= n / 2; i++){
// string y = "", x = "";
for(int j = lst + 1; j <= i; j++)x += s[j];
for(int j = (n - lst + 1) - (i - lst); j <= n - lst; j++)y += s[j];
// cout << i << "->" << x << ',' << y << endl;
if(x == y){
lst = i;
cnt += 2;
}
}
cout << cnt + 1 << endl;
}
}
