Skip to content

Instantly share code, notes, and snippets.

@ravikiran0606
Last active July 27, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravikiran0606/c6f059ca1084b28861dbad72c28b668c to your computer and use it in GitHub Desktop.
Save ravikiran0606/c6f059ca1084b28861dbad72c28b668c to your computer and use it in GitHub Desktop.
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment