atcoder#AGC021C. [AGC021C] Tiling
[AGC021C] Tiling
Score : points
Problem Statement
Takahashi has an grid, with horizontal rows and vertical columns. Determine if we can place tiles ( vertical, horizontal) and tiles ( vertical, horizontal) satisfying the following conditions, and construct one arrangement of the tiles if it is possible:
- All the tiles must be placed on the grid.
- Tiles must not stick out of the grid, and no two different tiles may intersect.
- Neither the grid nor the tiles may be rotated.
- Every tile completely covers exactly two squares.
Constraints
- , , and are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is impossible to place all the tiles, print NO
.
Otherwise, print the following:
YES
Here, must be one of the following characters: .
, <
, >
, ^
and v
. Represent an arrangement by using each of these characters as follows:
- When is
.
, it indicates that the square at the -th row and -th column is empty; - When is
<
, it indicates that the square at the -th row and -th column is covered by the left half of a tile; - When is
>
, it indicates that the square at the -th row and -th column is covered by the right half of a tile; - When is
^
, it indicates that the square at the -th row and -th column is covered by the top half of a tile; - When is
v
, it indicates that the square at the -th row and -th column is covered by the bottom half of a tile.
3 4 4 2
YES
<><>
^<>^
v<>v
This is one example of a way to place four tiles and three tiles on a grid.
4 5 5 3
YES
<>..^
^.<>v
v<>.^
<><>v
7 9 20 20
NO