Geek Sundaram attains inner peace...


Problem Statement :

https://www.codechef.com/ABCS2016/problems/ABACUS04

Problem Solution :

#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,x,y;
    map<int,int>m1,m2;
    long int n,i;
    cin>>t;
    while(t--){
       cin>>n;
       for(i=0;i<n;i++){
            cin>>x>>y;
            m1[x]++;
            m2[y]++;
       }
       int ans=min(m1.size(),m2.size());
       cout<<ans<<endl;
    }
    return 0;
}

No comments:

Post a comment