#P9687. Maps.

    ID: 10921 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>贪心洛谷原创O2优化构造洛谷月赛

Maps.

Problem Description

Xiao Y wants to get a map, but this map is a bit special.

This map is a grid with length nn units and width 11 unit. Each cell must be colored either white (00) or black (11).

You want to fulfill Xiao Y’s wish and give him such a map, but then Xiao Y提出 two more requirements:

  • For every white cell that is not at either end of the grid, there are exactly pp cells such that this cell’s left and right neighboring cells are both colored black.
  • While satisfying all the conditions above, the string formed by the characters from left to right is lexicographically smallest.

You think these requirements are easy, so you start creating.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, which denotes the number of test cases.

For each test case:

One line contains two integers n,pn, p, which denote the length of the map you need to construct and Xiao Y’s requirement.

Output Format

For each test case, output one line containing a 01 string of length nn, representing the map you construct. If it is impossible to find any map that satisfies Xiao Y’s requirements, output 1-1.

5
5 1
3 1
5 3
5 4
5 5
00101
101
-1
-1
-1

Hint

Sample Explanation #1

For the first test case: only the cell at the 44-th character satisfies that it is 00, is not on the border of the map, and both surrounding cells are 11, so it meets the condition. It can be proven that this is the lexicographically smallest solution that satisfies the conditions.

For the third test case: it can be proven that there is no solution with length 55 and with 33 cells such that the cell itself is 00, is not on the border, and both surrounding characters are 11.

Constraints

For all testdata, 1T1001 \le T \le 100, 1n,p1051 \le n, p \le 10^5.

This problem uses bundled tests. Test points with the same constraints are bundled into one Subtask\text{Subtask}.

The additional constraints for each test point are shown in the table below.

Test Point n,pn, p \le
131 \sim 3 1010
454 \sim 5 10310^3
6106 \sim 10 10510^5

Translated by ChatGPT 5