atcoder#ARC093B. [ABC092D] Grid Components

[ABC092D] Grid Components

Score : 500500 points

Problem Statement

You are given two integers AA and BB.

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 h×wh \times w (hh vertical, ww horizontal). Both hh and ww are at most 100100.
  • The set of the squares painted white is divided into exactly AA connected components.
  • The set of the squares painted black is divided into exactly BB 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, c1c_1 and c2c_2, are called connected when the square c2c_2 can be reached from the square c1c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.

A set of squares painted white, SS, forms a connected component when the following conditions are met:

  • Any two squares in SS are connected.
  • No pair of a square painted white that is not included in SS and a square included in SS is connected.

A connected component of squares painted black is defined similarly.

Constraints

  • 1A5001 \leq A \leq 500
  • 1B5001 \leq B \leq 500

Input

Input is given from Standard Input in the following format:

AA BB

Output

Output should be in the following format:

  • In the first line, print integers hh and ww representing the size of the grid you constructed, with a space in between.
  • Then, print hh more lines. The ii-th (1ih1 \leq i \leq h) of these lines should contain a string sis_i as follows:- If the square at the ii-th row and jj-th column (1jw1 \leq j \leq w) in the grid is painted white, the jj-th character in sis_i should be ..
    • If the square at the ii-th row and jj-th column (1jw1 \leq j \leq w) in the grid is painted black, the jj-th character in sis_i should be #.
2 3
3 3
##.
..#
#.#

This output corresponds to the grid below:

2701558bf42f7c088abad927b419472a.png

7 8
3 5
#.#.#
.#.#.
#.#.#
1 1
4 2
..
#.
##
##
3 14
8 18
..................
..................
....##.......####.
....#.#.....#.....
...#...#....#.....
..#.###.#...#.....
.#.......#..#.....
#.........#..####.