-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF-713A.cpp
41 lines (38 loc) · 967 Bytes
/
CF-713A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
using namespace std;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> ii;
vector<bool> get_pattern(string x) {
reverse(x.begin(), x.end());
while (x.size() <= 20)
x.push_back(0);
reverse(x.begin(), x.end());
vector<bool> pattern;
for (char c : x) {
int digit = c - '0';
pattern.push_back(digit % 2);
}
return pattern;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
map<vector<bool>, int> cnt;
while (t--) {
string type;
string value;
cin>>type>>value;
vector<bool> pattern = get_pattern(value);
if (type == "+") {
cnt[pattern] += 1;
} else if (type == "-") {
cnt[pattern] -= 1;
} else {
cout<<cnt[pattern]<<"\n";
}
}
}