시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
20 초 (추가 시간 없음) | 1024 MB | 0 | 0 | 0 | 0.000% |
Sherlock and Watson are playing a game involving bit strings, i.e., strings consisting only of the digits 0
and 1
. Watson has challenged Sherlock to generate a bit string S of N characters S1, S2, ..., SN. The string must obey each of K different constraints; each of these constraints is specified via three integers Ai, Bi, and Ci. The number of 1
s in the substring SAi, SAi + 1, ..., SBi must be equal to Ci.
Watson chooses the constraints in a way that guarantees that there is at least one string of the right length that obeys all of the constraints. However, since there could be multiple such strings, Watson wants Sherlock to choose the string from this set that is Pth in lexicographic order, with P counted starting from 1.
The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with one line containing three integers N, K, and P, as described above. Then, there are K more lines; the i-th of these contains three integers Ai, Bi and Ci, representing the parameters of the i-th constraint, as described above.
For each test case, output one line containing Case #x: y
, where x
is the test case number (starting from 1) and y
is the Pth lexicographically smallest bit string among all possible strings following the K specified constraints.
2 3 1 2 2 2 1 4 3 1 1 2 1 2 3 1 3 4 1
Case #1: 011 Case #2: 0101
Note that the last sample case would not appear in Small dataset.
In Sample Case #1, the bit strings that obey the only constraint in lexicographically increasing order are [010, 011, 110, 111].
In Sample Case #2, the bit strings that obey the given constraints in lexicographically increasing order are [0101, 1010].
Contest > Google > Kick Start > Google Kick Start 2018 > Round B B번