Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- using namespace std;
- int main()
- {
- int t; cin >> t;
- while (t--)
- {
- int n; cin >> n;
- unordered_map<string, pair<int, int>>mp;
- for (int i = 0; i < n; ++i)
- {
- string a;
- int b;
- cin >> a >> b;
- if (mp.find(a) == mp.end())
- {
- if (b == 0)mp.insert({a, {1, 0}});
- else mp.insert({a, {0, 1}});
- }
- else
- {
- if (b == 0)mp[a].first++;
- else mp[a].second++;
- }
- }
- int ans = 0;
- for (auto x : mp)
- {
- ans += max(x.second.first, x.second.second);
- }
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement