아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Paint By Numbers

시간 제한2초메모리 제한512 MB

요약
길이 n인 줄과 검은 칸 블록 길이 단서, 일부 미리 칠해진 칸이 주어질 때 모든 유효한 해에서 색이 고정된 칸을 찾는다.
난이도

보통10점 중 7점

유형
동적 계획법, 그리디
정답자
아직 제출이 없습니다

문제

Paint By Numbers is a well-known puzzle game. We consider a simple onedimensional version of this puzzle. In this puzzle, the player is given a row of n cells. The cells are numbered 0 through n - 1 from the left to the right. The player has to paint each cell black or white. We use ‘X’ to denote black cells and ‘_’ to denote white cells.

The player is given a sequence c = [c0, ..., c**k-1] of k positive integers: the clues. He has to paint the cells in a way such that the black cells in the row form exactly k blocks of consecutive cells. Moreover, the number of black cells in the i-th block (0 - based) from the left should be equal to ci. For example, if the clues are c = [3, 4], the solved puzzle must have exactly two blocks of consecutive black cells: one of length 3 and then another of length 4. Hence, if n = 10 and c = [3, 4], one solution satisfying the clues is “_XXX__XXXX”. Note that “XXXX_XXX__” does not satisfy the clues because the blocks of black cells are not in the correct order. Also, “__XXXXXXX_” does not satisfy the clues because there is a single block of black cells, not two separate blocks.

You are given a partially solved Paint By Numbers puzzle. That is, you know n and c, and additionally you know that some cells must be black and some cells must be white. Your task is to deduce additional information about the cells.

Specifically, a valid solution is one that satisfies the clues, and also agrees with the colors of the known cells. Your program should find cells that are painted black in every valid solution, and cells that are painted white in every valid solution.

You may assume that the input is such that there is at least one valid solution.

제한

In all subtasks 1 ≤ k ≤ n, and 1 ≤ ci ≤ n for each 0 ≤ i ≤ k - 1.

예제

이 문제는 공개된 예제가 없습니다.