fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. typedef vector <int> vi;
  5. typedef vector <vi> vii;
  6. typedef pair<int,int> pii;
  7. typedef int ft;
  8. #define get getchar_unlocked
  9. #define put putchar_unlocked
  10. #define pb push_back
  11. #define mp make_pair
  12. #define ff first
  13. #define ss second
  14. #define sz size()
  15. #define ln length()
  16. #define rep(i,n) for(int i=0;i<n;i++)
  17. #define ref(i,a,n) for(int i=a;i<=n;i++)
  18. #define reb(i,n,a) for(int i=n;i>=a;i--)
  19. #define all(a) a.begin(),a.end()
  20. #define gi(n) scanf("%d",&n)
  21. #define gii(n) scanf("%lld",&n)
  22. #define gc(c) scanf(" %c",&c)
  23. #define pi(n) printf("%d",n)
  24. #define pii(n) printf("%lld",n)
  25. #define pc(c) printf("%c",c)
  26. #define ps printf(" ")
  27. #define pn printf("\n")
  28. int gl(char *str) { char c; int i=0; while(!(scanf("%c",&c)==EOF || c=='\n')) str[i++]=c;str[i++]=' ';str[i]='\0'; return i;}
  29. void pl(char *str) { rep(i,strlen(str)) put(str[i]); }
  30. void gfi(ft &x) {
  31. register ft c = get(); x = 0; ft sn=1;
  32. for(;(c<48 || c>57);c = get()) if(c=='-') sn=-1;
  33. for(;c>47 && c<58;c = get()) {x = (x<<1) + (x<<3) + c - 48;}
  34. x*=sn;
  35. }
  36.  
  37. char str[10000000];
  38.  
  39. int main() {
  40. int t,n,flag=1,f;
  41. gfi(t);
  42. gl(str);
  43. while(strlen(str)==1) {
  44. gl(str);
  45. }
  46. while(t--) {
  47. // scanf("%s",str);
  48. if(flag) flag=0; else gl(str);
  49. n=strlen(str);
  50. // cout << str << " " << strlen(str) << endl;
  51. int ans=0,temp=0,prev=-1,curr=0,cnt=0;
  52. rep(i,n) {
  53. // cout << "cur: " << curr << " " << "pre: " << prev << endl;
  54. if(str[i]!=' ') temp++; else {
  55. f=1;
  56. // cout << temp << endl;
  57. if(temp)
  58. curr=temp;
  59. else f=0;
  60. if(curr==prev) {if(f) cnt++;} else cnt=0;
  61. ans=max(ans,cnt);
  62. temp=0;
  63. if(curr)
  64. prev=curr;
  65. }
  66. // cout << "cnt: " << cnt << endl;
  67. }
  68. if(strlen(str)==1) cout << "0" << endl;
  69. else cout << ans+1 << endl;
  70. }
  71. return 0;
  72. }
  73.  
Success #stdin #stdout 0s 12456KB
stdin
5
a
a
a
a
a
stdout
1
1
1
1
1