fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. string s;
  6. cin >> s;
  7. if (s.size() == 1) {
  8. cout << 1 << endl;
  9. return;
  10. }
  11. bool has_dupe = false;
  12. for (int i = 0; i < s.size() - 1; i++) {
  13. if (s[i] == s[i + 1]) {
  14. cout << 1 << endl;
  15. return;
  16. }
  17. }
  18. cout << s.size() << endl;
  19. }
  20.  
  21. int main() {
  22. int t;
  23. cin >> t;
  24. while (t--) solve();
  25. }
Success #stdin #stdout 0.01s 5288KB
stdin
4
baa
skibidus
cc
ohio
stdout
1
8
1
4