Connection Status:
Competition Arena > BoardCoveringDiv1
TCO19 SRM 741 · 2018-10-30 · by Blue.Mary · Recursion
Class Name: BoardCoveringDiv1
Return Type: String[]
Method Name: make
Arg Types: (int, int, int)
Problem Statement

Problem Statement

Lucyanna loves puzzles and she is always eager to invent new ones. She has recently invented a puzzle based on placing trominoes onto a square board.

The board is divided into a grid of unit squares. One of the unit squares on the board is black, all others are white.

A tromino is any connected piece that exactly covers three unit squares of the board. (Trominoes come in two shapes: "L" and "I".)

The goal of the puzzle is to cover all white squares of the board using trominoes. More precisely, the rules for Lucyanna's puzzle are as follows:

  • The player must place some trominoes onto the board.
  • Each tromino must exactly cover three unit squares of the board. (Thus, each tromino must lie completely inside the board.)
  • Each white unit square must be covered by exactly one tromino. (Thus, the trominoes cannot overlap.)
  • The black square must remain uncovered.

You are given the ints N, R and C. Your task is to find any valid solution for a N times N board on which the black square is in row R, column C. (Both indices are 0-based.) Once you have a solution, you need to color its trominoes using 10 non-black colors in such a way that adjacent trominoes always have different colors. (Trominoes are adjacent if they share a side of a unit square. You may assume that any valid solution can be colored in this way.)

If there are no solutions for the given N, R and C, return an empty String[]. Otherwise, return a String[] with R elements, each containing C characters. Use the characters '0'-'9' for the ten tromino colors and the character '#' for the uncovered black square.

Constraints

  • N will be between 1 and 47, inclusive.
  • R will be between 0 and N-1, inclusive.
  • C will be between 0 and N-1, inclusive.
Examples
0)
1
0
0
Returns: {"#" }
1)
2
1
1
Returns: {"00", "0#" }
2)
3
0
2
Returns: { }
3)
3
1
0
Returns: { }
4)
3
1
1
Returns: { }
57)
4
1
1
Returns: {"0011", "0#21", "3220", "3300" }

The example output represents the following 4x4 board with five trominoes: 0011 0#21 3220 3300

Submissions are judged against all 61 archived test cases, of which 6 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class BoardCoveringDiv1 with a public method vector<string> make(int N, int R, int C) · 61 test cases · 2 s / 256 MB per case

Submitting as anonymous