Paint the Map with Stains and Ink
Time limit1sMemory limit1024 MB
Given K, paint some cells of a 50x50 grid so that the monotone paths from (1,1) to (50,50) avoiding painted cells number exactly K.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Hanbyeol came across this problem while taking a probability and statistics class.
A map is made of cells. The cell in row and column is denoted . If one can move from to and to , how many ways are there to go from to ?
Hanbyeol thought this problem was too easy, so she wondered whether it would be fun to add stains and ink to some of the cells so that movement is blocked. She asked her friend Dubyeol to write a problem for her. The process is as follows.
- Dubyeol paints each () with stain or ink, or leaves it unpainted. Hanbyeol then finds the number of ways to move from to , where cells painted with stain or ink cannot be entered. If or is painted with stain or ink, the number of ways is 0.
Dubyeol wrote several problems for Hanbyeol, but found out that Hanbyeol kept getting the answers wrong. Not wanting her to be upset, Dubyeol used astrology to learn what answer she would give and decided to paint the map to match it. Painting the map to match that answer was not easy. Let us paint the stains and ink on the map in Dubyeol's place!
Input
The first line contains the integer , the answer Hanbyeol will say.
Output
Print the map Dubyeol makes as 50 lines, each containing 50 integers separated by spaces. The -th integer on the -th line is 1 if stain or ink is painted on the cell in the -th row from the bottom and the -th column from the left, and 0 if nothing is painted there.
The number of ways to reach the destination under the stated conditions for the printed map must be exactly .
Constraints
Hint
The answer to the original problem is .