Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- typedef long long ll;
- using namespace std;
- ll GetMask(ll a) {
- ll mask = 0;
- ll d = 1;
- while (a) {
- mask += (a & 1) * d;
- a /= 10;
- d *= 10;
- }
- return mask;
- }
- int main() {
- int n; cin >> n;
- unordered_map<ll, int> m;
- while (n--) {
- char command;
- ll value;
- cin >> command >> value;
- ll mask = GetMask(value);
- if (command == '+') {
- m[mask]++;
- } else if (command == '-') {
- m[mask]--;
- } else if (command == '?') {
- cout << m[mask] << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement