Advertisement
smatskevich

Seminar13

Feb 18th, 2023
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_map>
  3. using namespace std;
  4. typedef long long ll;
  5.  
  6. ll GetMask(ll value) {
  7.   ll ten_in_power = 1'000'000'000'000'000'000ll;
  8.   ll mask = 0;
  9.   while (ten_in_power > 0) {
  10.     if (value / ten_in_power % 2 == 1) mask += ten_in_power;
  11.     ten_in_power /= 10;
  12.   }
  13.   return mask;
  14. }
  15.  
  16. int main() {
  17.   int t = 0; cin >> t;
  18.   unordered_map<ll, int> m;
  19.   while (t--) {
  20.     char command = 0;
  21.     ll value = 0;
  22.     cin >> command >> value;
  23.     switch (command) {
  24.       case '+':
  25.         ++m[GetMask(value)];
  26. //        ll mask = GetMask(value);
  27. //        int& count = m[mask];
  28. //        count += 1;
  29. //        if (!m.contains(mask)) m[mask] = 1;
  30. //        else m[mask] += 1;
  31.         break;
  32.       case '-':
  33.         --m[GetMask(value)];
  34.         break;
  35.       case '?':
  36.         cout << m[GetMask(value)] << endl;
  37.         break;
  38.     }
  39.   }
  40.   return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement