[Solution] Queen Blocks CodeChef Solution
Problem
You are given an chessboard. Your enemy king is at point .
You need to place some number of queen pieces on the chessboard such that the following conditions are satisfied:
- The king should not be under attack by any of the queens that you have placed.
- The king should not be able to make any move.
Note that a king can move one unit in any of the direction while a queen can attack horizontally, vertically as well as diagonally.
Find the minimum number of queens required to satisfy the given conditions. Print the chessboard where denotes empty cells, denotes the king, and denotes the queen(s) placed by you in some position(s).
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains two space-separated integers and — the coordinates of the king.
Output Format
For each test case, output a grid consisting of King, Queen(s) and blank cells.
Print the chessboard in lines where each line has space-separated integers where denotes empty cells, denotes the king, and denotes the queen(s) placed by you in some position(s).
No comments:
Post a Comment