Submission #1322724

#TimeUsernameProblemLanguageResultExecution timeMemory
1322724JohanPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
0 ms332 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;
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...