Advertisement
Promi_38

cf 1551B1

Sep 25th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.     while(t--)
  10.     {
  11.         string s;
  12.         cin >> s;
  13.        
  14.         int freq[26], i, c1 = 0, c2 = 0;
  15.         for(i = 0; i < 26; i++) freq[i] = 0;
  16.         for(i = 0; i < s.length(); i++) freq[s[i] - 'a']++;
  17.         for(i = 0; i < 26; i++)
  18.         {
  19.             if(freq[i] == 1) c1++;
  20.             else if(freq[i] > 1) c2++;
  21.         }
  22.         printf("%d\n", c2 + (c1/2));
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement