Guest User

Untitled

a guest
Dec 18th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  5. #define INF 0x3f3f3f3f3f
  6.  
  7. int main() {
  8.  
  9.     fastio;
  10.  
  11.     ll test;
  12.     cin >> test;
  13.  
  14.     for(ll t = 0; t < test; t++){
  15.  
  16.         ll n , b;
  17.         string s;
  18.         ll c = 0;
  19.         map<string , pair<ll,ll> > m;
  20.  
  21.         cin >> n;
  22.         for(ll i = 0; i < n; i++){
  23.             cin >> s >> b;
  24.             auto it = m.find(s);
  25.             if(it == m.end()){
  26.                 if(b == 0) m.insert(make_pair(s , make_pair(1,0)));
  27.                 else m.insert(make_pair(s , make_pair(0,1)));
  28.             }
  29.             else{
  30.                 if(b == 0) it.second.first++;
  31.                 else it.second.second++;
  32.             }
  33.         }
  34.  
  35.         for(auto x : m) c += max(x.second.first , x.second.second);
  36.  
  37.         cout << c << "\n";
  38.     }
  39.     return 0;
  40. }
Add Comment
Please, Sign In to add comment