
2005
ASIA PROGRAMMING CONTEST – MANILA
October
29, 2005
Input File: f.in
Limit: 2 seconds
In chess, a king (K) checks any piece that is 1 position away from him; a queen (Q) checks any piece that is in
the same row, column, or diagonal where she is unless obstructed; a bishop (B) checks any piece that is at
the same diagonal where he is unless obstructed; a rook (R) checks any piece that is at the same row or column where
he is unless obstructed; a knight (N)
checks any piece that is located in an L position from where he is (2 columns
and 1 row away, or 1 column and 2 rows away) even with obstruction.
Write a program that checks which chess pieces
(K, Q, B, R, N) checks which chess pieces on an 8 x 8 chess board.
Input
The input file consists of 1 to 50 lines (each being a test case) of chess piece assignments (row position and column position for each chess piece). There can be 2 to 20 chess pieces of any type for each test case. Assume that no two pieces have the same position. Also, assume that all input cases are in the same format as the examples and are valid.
Output
For each of the test cases, output which
piece at which row and column checks which piece at which row and column. This
check-list should be sorted by row and column of the checker, and then by row
and column of the piece checked. If no piece checks any piece, display “All
pieces safe.”
|
Case 1:
Q86B31N22R71Q45R13N12N67K84 Case 2:
Q57Q61Q26Q38Q42Q73Q85 Case 3:
K22K11K12K21 |
Case 1: N12-B31 R13-N12 B31-N22 B31-Q86 Q45-N12 Q45-N67 N67-Q86 R71-B31 Q86-B31 Q86-K84 Case 2: All pieces safe. Case 3: K11-K12 K11-K21 K11-K22 K12-K11 K12-K21 K12-K22 K21-K11 K21-K12 K21-K22 K22-K11 K22-K12 K22-K21 |