Submission #915652

# Submission time Handle Problem Language Result Execution time Memory
915652 2024-01-24T13:19:16 Z toonewbie Palindromic Partitions (CEOI17_palindromic) C++17
0 / 100
1 ms 348 KB
#pragma GCC optimize("O3")
#include <iostream>

using namespace std;

int n;
string s;

bool check_equal(int a, int b, int l) {
  for (int i = 0; i < l; i++) {
    if (s[a + i] != s[b + i]) {
      return false;
    }
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while(T--) {
    cin >> s;
    n = s.size();
    int res = 0;
    
    int l = 0, r = n - 1;
    while(l < r) {
      int len = 1;
      while (l + len <= r && !check_equal(l, r - len + 1, len)) {
        len++;
      }
      res += 2;
      l += len;
      r -= len;
    }
    if (l == r) {
      res++;
    } else if (l > r) {
      res--;
    }
    cout << res << "\n";
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -