Tree Planting
Time limit2sMemory limit1024 MB
Decide if a connected set of grid cells exists with A cells of even neighbor count and B of odd, and print one layout.
- Level
Medium6 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Seunghyeon wants to plant trees. To do so, Seunghyeon picks some cells on an infinite grid and scatters tree seeds on them. The seeds have a mysterious power. Under the influence of nearby seeds, each seed grows into either an apple tree or a peach tree.
Two seeds are called adjacent if they sit in cells that share an edge. A seed with an even number of adjacent seeds becomes an apple tree. A seed with an odd number of adjacent seeds becomes a peach tree.

Suppose Seunghyeon plants 5 seeds as shown above. The blue arrows mark the adjacent seeds. The middle seed has 3 adjacent seeds, so it becomes a peach tree.

In this case, 3 apple trees and 2 peach trees grow.
All seeds must be connected on the grid. That is, for any two seeds, you must be able to travel between them using only adjacent seeds. For example, the layout below is impossible.

Seunghyeon wants to plant apple trees and peach trees. Determine whether this is possible, and if it is, print a layout of the trees.
Input
The first line contains non-negative integers and , separated by a space. (; ; )
Output
On the first line, print YES if the layout is possible, and NO otherwise.
If the layout is possible, print and , the number of rows and columns, separated by a space on the second line. ()
On the following lines, print characters per line with no spaces. Each character is O or .. Print O where a seed is planted and . where there is none.