Three Cells per Row and Column

AtCoder
IDagc056_a
Time2000ms
Memory256MB
Difficulty
We have a grid board with $N$ rows and $N$ columns. Paint every square black or white to satisfy all of the conditions below. * For each row, exactly three of the squares in that row are painted black. * For each column, exactly three of the squares in that column are painted black. * There are exactly $N$ connected components of black squares. Here, two black squares $x$ and $y$ are considered connected when it is possible to start at $x$ and reach $y$ by repeatedly moving up, down, left, or right to a black square. It can be proved that the Constraints of the problem guarantee the existence of a solution. ## Constraints * $6 \leq N \leq 500$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
6
Output #1
##..#.
##..#.
..##.#
..##.#
##...#
..###.

Here, there are exactly $3$ `#`s in each row and column. Additionally, there are exactly $6$ connected components of `#`s.
API Response (JSON)
{
  "problem": {
    "name": "Three Cells per Row and Column",
    "description": {
      "content": "We have a grid board with $N$ rows and $N$ columns. Paint every square black or white to satisfy all of the conditions below. *   For each row, exactly three of the squares in that row are painted bl",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc056_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a grid board with $N$ rows and $N$ columns.\nPaint every square black or white to satisfy all of the conditions below.\n\n*   For each row, exactly three of the squares in that row are painted bl...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments