/* Queen Collison, MCPC 2010 Problem D, C++ solution by Michael Goldwasser */ #include #include #include using namespace std; fstream fin("collision.in"); int main() { int n,g; fin >> n; while (n > 0) { /* * tallies[0][x] tracks each row from 1 to n * tallies[1][y] tracks each column from 1 to n * tallies[2][x+y] tracks each diagonal from 2 to 2*n * tallies[3][n+1+x-y] tracks each reverse diagonal from 2 to 2*n */ int tallies[4][2*n+1]; for (int j=0; j<4; j++) for (int k=0; k <= 2*n; k++) tallies[j][k] = 0; fin >> g; for (int i=0; i> k >> x >> y >> s >> t; for (int j=0; j 1) count += (tallies[j][k] - 1); cout << count << endl; fin >> n; } }