atcoder#ARC093B. [ABC092D] Grid Components
[ABC092D] Grid Components
Score : points
Problem Statement
You are given two integers and .
Print a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:
- Let the size of the grid be ( vertical, horizontal). Both and are at most .
- The set of the squares painted white is divided into exactly connected components.
- The set of the squares painted black is divided into exactly connected components.
It can be proved that there always exist one or more solutions under the conditions specified in Constraints section. If there are multiple solutions, any of them may be printed.
Notes
Two squares painted white, and , are called connected when the square can be reached from the square passing only white squares by repeatedly moving up, down, left or right to an adjacent square.
A set of squares painted white, , forms a connected component when the following conditions are met:
- Any two squares in are connected.
- No pair of a square painted white that is not included in and a square included in is connected.
A connected component of squares painted black is defined similarly.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Output should be in the following format:
- In the first line, print integers and representing the size of the grid you constructed, with a space in between.
- Then, print more lines. The -th () of these lines should contain a string as follows:- If the square at the -th row and -th column () in the grid is painted white, the -th character in should be
.
.- If the square at the -th row and -th column () in the grid is painted black, the -th character in should be
#
.
- If the square at the -th row and -th column () in the grid is painted black, the -th character in should be
2 3
3 3
##.
..#
#.#
This output corresponds to the grid below:
7 8
3 5
#.#.#
.#.#.
#.#.#
1 1
4 2
..
#.
##
##
3 14
8 18
..................
..................
....##.......####.
....#.#.....#.....
...#...#....#.....
..#.###.#...#.....
.#.......#..#.....
#.........#..####.