描述 There are N queens in an infinite chessboard. We say two queens may attack each other if they are in the same vertical line, horizontal line or diagonal line even if there are other queens sitting between them.
Now given the positions of the queens, find out how many pairs may attack each other?
输入 The first line contains an integer N. Then N lines follow. Each line contains 2 integers Ri and Ci indicating there is a queen in the Ri-th row and Ci-th column. No two queens share the same position. For 80% of the data, 1 <= N <= 1000 For 100% of the data, 1 <= N <= 100000, 0 <= Ri, Ci <= 1000000000
输出 One integer, the number of pairs may attack each other.
intmain(){ int data[100000+1][2]; int n ; while (cin>>n) { memset(data, 0, sizeof(data)); for (int i = 0; i < n; i ++) { cin >> data[i][0] >>data[i][1 ]; } long count = 0; for (int i = 0; i < n; i ++) { for (int j = i+1; j < n; j ++) { if(judge(data[i][0],data[i][1],data[j][0],data[j][1])){ count ++; } } } cout<<count<<endl; } return0; }