시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 14 | 9 | 9 | 64.286% |
Flow Free is a puzzle that is played on a 2D grid of cells, with some cells marked as endpoints of certain colors and the rest of cells being blank.
To solve the puzzle, you have to connect each pair of colored endpoints with a path, following these rules:
The rules imply that different colored paths cannot intersect.
The path is defined as a connected series of segments where each segment connects two neighbouring cells. Two cells are neighbours if they share a side (so all segments are either horizontal or vertical). By these definitions and rules above, each colored cell will be an endpoint of exactly one segment and each blank cell will be an endpoint of exactly two segments.
In this problem we will consider only the 4 × 4 puzzle, with 3 or 4 pairs of colored endpoints given.
Your task is to determine if a given puzzle is solvable or not.
The input consists of 4 lines, each line containing 4 characters. Each character is from the set {R, G, B, Y, W} where W denotes the blank cells and the other characters denote endpoints with the specified color. You are guaranteed that there will be exactly 3 or 4 pairs of colored cells. If there are 3 colors in the grid, Y will be omitted.
On a single line output either “solvable” or “not solvable” (without the quotes).
RGBW WWWW RGBY YWWW
solvable
RGBW WWWW RGBW YWWY
not solvable