Plabon_dutta

Codeforces Round #734 (Div. 3), problem: (B1) Wonderful Coloring - 1

Jul 23rd, 2021
1,591
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define pi acos(-1.0)
  6. #define ll long long int
  7. #define sc scanf
  8. #define pf printf
  9. #define fin for(ll i=0; i<n; i++)
  10. #define fjm for(ll j=0; j<m; j++)
  11. #define fr(i,a,n) for(ll i=a; i<n; i++)
  12. #define rf(i,n,a) for(ll i=n-1; i>=a; i--)
  13. #define nl "\n"
  14. #define readfirst() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
  15.  
  16. ll gcd(ll p, ll q) {
  17.     return q==0?p:gcd(q,p%q);
  18. }
  19.  
  20. int main() {
  21.     readfirst();
  22.     ll t;
  23.     cin >> t;
  24.     while(t--) {
  25.         string s;
  26.         cin >> s;
  27.         ll n=s.size(), c=0, f=0;
  28.         if(n>=2) {
  29.             unordered_map<char,int>m;
  30.             fin m[s[i]]++;
  31.             for(auto x: m) {
  32.                 if(x.second>2) f+=2;
  33.                 else f+=x.second;
  34.             }
  35.             c=f/2;
  36.         }
  37.         cout << c << nl;
  38.     }
  39.     return 0;
  40. }
RAW Paste Data