MohamedAbdel3al

B1. Wonderful Coloring - 1

Sep 9th, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6.  
  7.  
  8. void ABDEL3AL () {
  9. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  12. #endif
  13.  
  14. }
  15.  
  16. int main() {
  17. ABDEL3AL() ;
  18. int t ; cin >> t ;
  19. int freq[26] = {0} ;
  20. while (t--) {
  21. int cnt = 0 ;
  22. string s ; cin >> s ;
  23. for (int i = 0; i < sz(s); i++) freq[s[i] - 'a']++ ;
  24. for (int i = 0; i < 26; i++)
  25. if (freq[i]) cnt += min(freq[i] , 2) ;
  26. cout << cnt / 2 << "\n" ;
  27. }
  28.  
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment