fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main() {
  5. ll q; cin >> q;
  6. cin.ignore();
  7. for (ll _ = 1; _ <= q; _++)
  8. {
  9.  
  10. string s; getline(cin, s);
  11. vector < ll > a;
  12. ll t = 0;
  13.  
  14. for (char i : s)
  15. {
  16. if (i != ' ')
  17. {
  18. t++;
  19. }
  20. else
  21. {
  22. if (t > 0) a.push_back(t);
  23. t = 0;
  24. }
  25. }
  26. if (t > 0) a.push_back(t);
  27. ll _max = 1;
  28. ll tmp = 1;
  29.  
  30. for (ll i = 1; i <= a.size(); i++)
  31. {
  32. if (a[i] == a[i - 1]) tmp++;
  33. else
  34. {
  35. tmp = 1;
  36. }
  37. _max = max(_max, tmp);
  38. }
  39. if (_ != q) cout << _max << endl;
  40. else cout << _max;
  41.  
  42. }
  43.  
  44. }
  45.  
Success #stdin #stdout 0.01s 5300KB
stdin
2
a aa bb cc def ghi
a a a a a bb bb bb bb c c
stdout
3
5