Advertisement
hemel18681

24.01.2020 sesison code

Jan 24th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--){
  8. int alp=0,num=0;
  9. string s;
  10. cin>>s;
  11. for(int i=0;i<s.length();i++){
  12. if(s[i]>='a'&&s[i]<='z') alp++;
  13. else num++;
  14. }
  15. int mi=(min(alp,num)*2);
  16. //cout<<mi<<endl;
  17. alp=0;
  18. num=0;
  19. deque<char> d;
  20. for(int i=0;i<s.length();i++){
  21. if(s[i]>='a'&&s[i]<='z') alp++;
  22. else num++;
  23. d.push_back(s[i]);
  24. if(d.size()>mi){
  25. if(d.front()>='a'&&d.front()<='z'){
  26. alp--;
  27. }
  28. else{
  29. num--;
  30. }
  31. d.pop_front();
  32. }
  33. cout<<alp<<" "<<num<<" "<<i+1<<endl;
  34. }
  35. if(alp+num==mi&&alp==num){
  36. cout<<mi<<endl;
  37. }
  38. else if(mi==2&&s.length()>2) cout<<mi<<endl;
  39. else cout<<mi-2<<endl;
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement