pangfengliu / programmingtasks

programming tasks from my courses
67 stars 17 forks source link

N-pieces (special judge) #319

Open morris821028 opened 8 years ago

morris821028 commented 8 years ago

Problem Description

Given a chessboard of $n$ by $n$, is it possible to place m pieces in it so that no more than $k$ pieces appear in each row, each column, and each 45 degree line? Note that there are two 45 degree lines for a cell $(x, y)$ not in the corners. That is, the first one goes through … $(x-1, y + 1)$, $(x, y)$, $(x + 1, y -1)$, … and the second one goes through $(x + 1, y + 1)$, $(x, y)$, $(x - 1, y - 1)$, …

p10074-board

p10074-limit

Subtasks

n1 m1 k1
n2 m2 k2
...(until EOF)

For each line, you have to find out whether it is possible or not to place m pieces in a chessboard of $n$ by $n$ so that no more than $k$ pieces appear in each row, each column, and each 45 degree line.

Output Format

If it is possible to place $m$ pieces in the chessboard, print one possible solution.

If it is not possible to place m pieces in the chessboard, print N.

Sample Input

3 6 2
2 3 1
8 8 1

Sample Output

oo.
o.o
.oo
N
o.......
....o...
.......o
.....o..
..o.....
......o.
.o......
...o....