fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, a[100005], b[100005], x, y, cntx, cnty;
  8. scanf("%d", &n);
  9. memset(a, 0, sizeof(a));
  10. memset(b, 0, sizeof(b));
  11. cntx=cnty=0;
  12. for(int i=0; i<n; i++) {
  13. scanf("%d%d", &x, &y);
  14. if(a[x]==0) a[x]++, cntx++;
  15. if(b[y]==0) b[y]++, cnty++;
  16. }
  17. if(cntx<cnty) printf("%d\n", cntx);
  18. else printf("%d\n", cnty);
  19. return 0;
  20. }
Success #stdin #stdout 0s 4008KB
stdin
4
1 1
1 2
2 3
3 3
stdout
3