#include #include #include #include #include using namespace std; int n; typedef pair position; bool isBakon(position &p1,position &p2){ if(p1.first == p2.first) return true; if(p1.second == p2.second) return true; if(abs(p1.first-p2.first) == abs(p1.second - p2.second)) return true; return false; } inline decboard(int board[50][50], position &p1) { for(int i = 1 ; i < n ; i ++){ int x1 = p1.first - i; int x2 = p1.first + i; int y1 = p1.second - i; int y2 = p1.second + i; if(x1 >= 0 && y1 >= 0) board[x1][y1] --; if(x2 < n && y1 >= 0) board[x2][y1] --; if(x1 >= 0 && y2 < n) board[x1][y2] --; if(x2 < n && y2 < n) board[x2][y2] --; } } inline incboard(int board[50][50], position &p1) { for(int i = 1 ; i < n ; i ++){ int x1 = p1.first - i; int x2 = p1.first + i; int y1 = p1.second - i; int y2 = p1.second + i; if(x1 >= 0 && y1 >= 0) board[x1][y1] ++; if(x2 < n && y1 >= 0) board[x2][y1] ++; if(x1 >= 0 && y2 < n) board[x1][y2] ++; if(x2 < n && y2 < n) board[x2][y2] ++; } } int main(void) { int board[50][50]; // int n; cin >> n; int i; vector poss; for(i = 0 ; i < n ; i ++){ int x,y; cin >> x >> y; poss.push_back(pair(x-1,y-1)); } int ul = 0; // vector > results; for(int y = 0 ; y < n ; y ++){ for(int x = 0 ; x < n ; x ++){ board[x][y] = 0; } } for( int k = 0 ; k < n ; k ++){ // if(k == first || k == second || k == third) continue; for(int i = 1 ; i < n ; i ++){ // board[poss[k].first][i] ++; // board[i][poss[k].second] ++; // if( i > 0){ int x1 = poss[k].first - i; int x2 = poss[k].first + i; int y1 = poss[k].second - i; int y2 = poss[k].second + i; if(x1 >= 0 && y1 >= 0) board[x1][y1] ++; if(x2 < n && y1 >= 0) board[x2][y1] ++; if(x1 >= 0 && y2 < n) board[x1][y2] ++; if(x2 < n && y2 < n) board[x2][y2] ++; // } } } // board maked for(int first= 0 ; first< n - 2 ; first++){ for(int second = first + 1 ; second < n - 1 ; second ++){ for(int third = second + 1 ; third < n ; third ++){ decboard(board, poss[first]); decboard(board, poss[second]); decboard(board, poss[third]); vector toplace; vector xs; xs.push_back(poss[first].first); xs.push_back(poss[second].first); xs.push_back(poss[third].first); vector ys; ys.push_back(poss[first].second); ys.push_back(poss[second].second); ys.push_back(poss[third].second); for(i = 0; i< 3; i++){ for(int j = 0; j < 3; j++){ if(board[xs[i]][ys[j]] ==0) toplace.push_back(make_pair(xs[i], ys[j])); } } /* cout << "u " << toplace.size() << endl; for(i = 0 ; i < toplace.size() ; i ++){ cout << toplace[i].first << "," << toplace[i].second << endl; } */ for(i = 0 ; i < toplace.size()-2 ; i ++){ for(int t = i+1 ; t < toplace.size() - 1 ; t ++){ if(isBakon(toplace[i],toplace[t]) == false) for(int j = t + 1 ; j < toplace.size() ; j++){ // cout << "uhoho" << endl; if(isBakon(toplace[i],toplace[j]) == false && isBakon(toplace[t],toplace[j]) == false){ // cout << "uhohohoho" << endl; vector result; result.push_back(toplace[i]); result.push_back(toplace[t]); result.push_back(toplace[j]); if(find(result.begin(), result.end(), poss[first]) != result.end()) continue; if(find(result.begin(), result.end(), poss[second]) != result.end()) continue; if(find(result.begin(), result.end(), poss[third]) != result.end()) continue; /* for(int k = 0; k < n; k++){ if(k == first || k == second || k == third) continue; else result.push_back(poss[k]); }*/ ul ++; /* sort(result.begin(), result.end()); if(find(results.begin(), results.end(), result) == results.end()) results.push_back(result); */ } } } } incboard(board, poss[first]); incboard(board, poss[second]); incboard(board, poss[third]); } } } cout << ul << endl; }