Advertisement
newb_ie

Untitled

Aug 29th, 2021
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. //Bismillahir Rahmanir Rahim
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int main()
  5. {
  6.  
  7. freopen ("in.txt", "r", stdin);
  8.  
  9. freopen ("out.txt", "w", stdout);
  10. int T;
  11. cin >> T;
  12. int p=1;
  13. for(int tc=0; tc<T; tc++)
  14. {
  15.  
  16. string s;
  17. cin>>s;
  18. cout<<"Case #"<<p<<":";
  19. p++;
  20. int cons=0;
  21. int vowel=0;
  22. int count[26];
  23. int hi = 0,bye = 0;
  24. int mp = 0;
  25. fill(count,count + 26,0);
  26.  
  27. for (int i = 0; i < (int) s.size(); ++i) {
  28. count[s[i] - 'A']++;
  29. if (s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'U') {
  30. ++vowel;
  31. bye = max(bye,count[s[i] - 'A']);
  32. } else {
  33. ++cons;
  34. hi = max(hi,count[s[i] - 'A']);
  35. }
  36. }
  37. mp = hi;
  38. int c2=(cons-mp);
  39. int c3=(c2*2)+vowel;
  40. int v1=vowel-bye;
  41. int v2=(v1*2)+cons;
  42. cout<<min(c3,v2)<<endl;
  43. }
  44. }
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement