#P7938. 「Wdcfr-1」Beautiful Array
「Wdcfr-1」Beautiful Array
题目描述
In this problem, we define a sequence of ( and ) as a "bracket sequence".
The definition of Regular Bracket Sequence is as follows:
()is a Regular Bracket Sequence.- If
Ais a Regular Bracket Sequence, then(A)is also a Regular Bracket Sequence. - If
AandBare Regular Bracket Sequences, thenABis also a Regular Bracket Sequence.
For example: (), (()), and ()() are all Regular Bracket Sequences, but )(, ()( are not.
In particular, an empty sequence is not a Regular Bracket Sequence sequence in this problem.
Now cute Ran gives you a bracket sequence of length . She wants you to construct strictly increasing arrays. Let us denote them as
(you can leave any of them empty). You need to ensure that all integers between appear exactly once in these arrays.
An array is Beautiful if is a Regular Bracket Sequence.
Ran wonders whether it is possible to construct these arrays so that at least of the arrays are "beautiful arrays".
输入格式
Each test contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers and , and the second line contains a bracket sequence .
输出格式
For each test case, print one line.
If it is possible to construct these arrays, print . Otherwise print .
2
2 1
()
2 99
()
1
0
提示
Explanation
For the first test case, we can construct and . So is a "beautiful array".
For the second test case, it is obvious that we cannot use two numbers to construct beautiful arrays.
Constraints
.