#P8467. [Aya Round 1 B] 甲(one)
[Aya Round 1 B] 甲(one)
Problem Description
A sequence of length is defined as “good” if and only if there exists a permutation of length such that and . Now you are given an integer sequence of length , satisfying . Among them, are given. Determine whether there exists an such that is “good”.
Here, a permutation of length means a sequence of length in which each appears exactly once.
Input Format
This problem contains multiple test cases.
- The first line contains an integer , the number of test cases.
- The next lines each contain four integers , representing one test case.
Output Format
- Output lines in total. For each test case, if there exists an that satisfies the condition, output ; otherwise output .
5
3 2 8 4
1 2 3 4
1 9 4 9
1 0 0 1
0 0 4 2
1
1
0
0
1
Hint
Additional Samples
- Sample can be found in the distributed file . This sample satisfies the constraints of test point .
- Sample can be found in the distributed file . This sample satisfies the constraints of test point .
Sample Explanation
Sample #1
- For the st test case, we can set . Then there exists such that and . Therefore output .
- For the nd test case, we can set . Then there exists such that and . Therefore output .
- For the rd test case, there is no that can make “good”.
Constraints
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|} \hline \textbf{\textsf{Test Point}} & \bm{{T\le}} & \textbf{\textsf{Special Property}} \cr\hline 1 & 100 & \textbf{A} \cr\hline 2 & 100 & \textbf{B} \cr\hline 3 & 100 & - \cr\hline 4 & 1000 & - \cr\hline 5 & 10^5 & - \cr\hline \end{array}$$- Special property : .
- Special property : are pairwise distinct.
For of the testdata, , .
Translated by ChatGPT 5