Tiling

AtCoder
IDagc021_c
Time2000ms
Memory256MB
Difficulty
Takahashi has an $N \times M$ grid, with $N$ horizontal rows and $M$ vertical columns. Determine if we can place $A$ $1 \times 2$ tiles ($1$ vertical, $2$ horizontal) and $B$ $2 \times 1$ tiles ($2$ vertical, $1$ 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 * $1 \leq N,M \leq 1000$ * $0 \leq A,B \leq 500000$ * $N$, $M$, $A$ and $B$ are integers. ## Input Input is given from Standard Input in the following format: $N$ $M$ $A$ $B$ [samples]
Samples
Input #1
3 4 4 2
Output #1
YES
<><>
^<>^
v<>v

This is one example of a way to place four $1 \times 2$ tiles and three $2 \times 1$ tiles on a $3 \times 4$ grid.
Input #2
4 5 5 3
Output #2
YES
<>..^
^.<>v
v<>.^
<><>v
Input #3
7 9 20 20
Output #3
NO
API Response (JSON)
{
  "problem": {
    "name": "Tiling",
    "description": {
      "content": "Takahashi has an $N \\times M$ grid, with $N$ horizontal rows and $M$ vertical columns. Determine if we can place $A$ $1 \\times 2$ tiles ($1$ vertical, $2$ horizontal) and $B$ $2 \\times 1$ tiles ($2$ v",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc021_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Takahashi has an $N \\times M$ grid, with $N$ horizontal rows and $M$ vertical columns. Determine if we can place $A$ $1 \\times 2$ tiles ($1$ vertical, $2$ horizontal) and $B$ $2 \\times 1$ tiles ($2$ v...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments