Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define INF 0x3f3f3f3f3f
- int main() {
- fastio;
- ll test;
- cin >> test;
- for(ll t = 0; t < test; t++){
- ll n , b;
- string s;
- ll c = 0;
- map<string , pair<ll,ll> > m;
- cin >> n;
- for(ll i = 0; i < n; i++){
- cin >> s >> b;
- auto it = m.find(s);
- if(it == m.end()){
- if(b == 0) m.insert(make_pair(s , make_pair(1,0)));
- else m.insert(make_pair(s , make_pair(0,1)));
- }
- else{
- if(b == 0) it.second.first++;
- else it.second.second++;
- }
- }
- for(auto x : m) c += max(x.second.first , x.second.second);
- cout << c << "\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment