Advertisement
Korotkodul

CF

Mar 28th, 2023 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. #include <algorithm>
  5. #define pb push_back
  6. using namespace std;
  7.  
  8.  
  9.  
  10. void f()
  11. {
  12.     set <char> all;
  13.     vector <char> v;
  14.     for (int i = 0; i < 4; ++i) {
  15.         char k; cin >> k;
  16.         all.insert(k);
  17.         v.pb(k);
  18.     }
  19.     if (all.size() == 1) {
  20.         cout <<  -1;
  21.         exit(0);
  22.     }
  23.     if (all.size() == 2) {
  24.         int x = count(v.begin(), v.end(), v[0]);
  25.         if (x == 1 || x == 3) {
  26.             cout << 6;
  27.             exit(0);
  28.         }
  29.     }
  30.     cout << 4;
  31. }
  32.  
  33. int main()
  34. {
  35.     int t; cin >> t;
  36.     for (int i = 0; i < t; ++i) {
  37.         f();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement