#include using namespace std; const int MAXSIZE = 1000; char board[MAXSIZE+4][MAXSIZE+4]; // +2 to allow for easy processing of knight moves bool safe[MAXSIZE+4][MAXSIZE+4]; int numsafe; void process(int i, int j) { if (safe[i][j]) numsafe--; safe[i][j] = false; } int main() { int n, m, i, j, k; int nboard = 0; cin >> n >> m; while (n != 0) { nboard++; for(i=2; i> num; for(i=0; i> r >> c; board[r+1][c+1] = 'q'; } cin >> num; for(i=0; i> r >> c; board[r+1][c+1] = 'k'; } cin >> num; for(i=0; i> r >> c; board[r+1][c+1] = 'p'; } for(i=2; i=2; k--) { if (board[k][j] != ' ') break; process(k, j); } for(k=i+1; k=2; k--) { if (board[i][k] != ' ') break; process(i, k); } for(k=j+1; k=2; k--) { if (board[k][j+k-i] != ' ') break; process(k, j+k-i); } for(k=i+1; k=2; k--) { if (board[k][j+i-k] != ' ') break; process(k, j+i-k); } for(k=i+1; k> n >> m; } return 0; }