CSES - Grid Puzzle I | Câu đố trên lưới I

View as PDF



Authors:
Problem types
Points: 1900 (p) Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

There is an \(n×n\) grid whose each square has some number of coins in it. How can you do that?

Input

  • The first input line has an integer \(n\): the size of the grid. The rows and columns are numbered \(1,2,…,n\).
  • The next line has n integers \(a_1,a_2,…,a_n\): You must choose exactly \(a_i\) squares from the \(i\)th row.
  • The next line has n integers \(b_1,b_2,…,b_n\): You must choose exactly \(b_j\) squares from the \(j\)th column.

Output

  • Print n lines describing which squares you choose (\(X\) means that you choose a square, \(.\) means that you don't choose it). You may print any valid solution.
  • If it is not possible to satisfy the conditions print only \(−1\).

Constraints

  • \(1\leq n \leq 50\)
  • \(1\leq a_i \leq n\)
  • \(1\leq b_j \leq n\)

Example

Sample input

5  
0 1 3 2 0  
1 2 2 0 1  

Sample output

.....  
..X..  
.XX.X  
XX...  
.....

Comments (2)

Most recent
Loading comments...