F.cpp 492 B

1234567891011121314151617181920212223
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool ok(const string &s) {
  4. if (s.length() == 0 || s.length() % 2 != 0) return false;
  5. for (int i = 0; i < s.length() / 2; i++)
  6. if (s[i] != s[s.length() - 1 - i]) return false;
  7. return true;
  8. }
  9. int main(int argc, char const *argv[]) {
  10. int n;
  11. cin >> n;
  12. while (n--) {
  13. string s;
  14. cin >> s;
  15. while (ok(s)) s = s.substr(0, s.length() / 2);
  16. cout << s.length() << endl;
  17. }
  18. return 0;
  19. }