fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int const MaxN=2000;
  5. int N;
  6. struct NODE{
  7. int x,y;
  8. NODE(int x=0,int y=0):x(x),y(y){}
  9. };
  10. NODE node[MaxN];
  11. bool comp(NODE lhs,NODE rhs){
  12. return (lhs.y!=rhs.y)? lhs.y<rhs.y:lhs.x<rhs.x;
  13. }
  14.  
  15. int Cmath(int num,int k){
  16. if(num<k){
  17. return 0;
  18. }
  19. int ans=1;
  20. for(int i=1;i<=num;i++){
  21. ans*=i;
  22. }
  23. for(int o=1;o<=k;o++){
  24. ans/=o;
  25. }
  26. for(int o=1;o<=(num-k);o++){
  27. ans/=o;
  28. }
  29. return ans;
  30. }
  31.  
  32. int main() {
  33. int A,B;
  34. cin>>N;
  35. for(int n=0;n<N;n++){
  36. cin>>A>>B;
  37. node[n]=NODE(A,B);
  38. }
  39. sort(node,node+N,comp);
  40. int same=0,ansnum=0;
  41. for(int n=0;n<N;n++){
  42. if(node[n].y==node[n+1].y){
  43. for(int m=n+1;m<N;m++){
  44. if(node[m].y==node[m+1].y){
  45. if(node[n].x==node[m].x){
  46. same++;
  47. }
  48. }else{
  49. same++;
  50. }
  51. }
  52. }
  53. cout<<same<<"\n";
  54. ansnum+=Cmath(same,2);
  55. same=0;
  56. }
  57. /*for(int n=0;n<N;n++){
  58. cout<<node[n].x<<" "<<node[n].y<<"\n";
  59. }*/
  60. cout<<ansnum;
  61. return 0;
  62. }
Success #stdin #stdout 0s 5316KB
stdin
6
0 0
0 1
1 0
1 1
2 0
2 1
stdout
3
3
0
1
1
0
6