#P9492. 「SFCOI-3」进行一个拆的解
「SFCOI-3」进行一个拆的解
Background
Announcement: The Subtask 0 testdata was incorrect and has now been fixed.
Three-year-old Xiao Ming really dislikes complete things. He even wants to split sequences apart.
Problem Description
Given a sequence , Xiao Ming wants to split it into two subsegments and , i.e., and .
Because Xiao Ming is very obsessive, he does not want, for these two subsegments, one to be a subsequence of the other. In other words, he does not want one subsegment to be able to become the other by deleting some (possibly ) elements.
When his parents are out, Xiao Ming finally finds a chance to split the sequence. So he wants to know whether there exists a way to split it such that neither subsegment is a subsequence of the other.
Input Format
The first line contains an integer , meaning Xiao Ming will split sequences in total. Then follow lines, each describing a sequence:
- The first integer in each line is , the length of the sequence.
- The next integers are the elements of the sequence in order.
Output Format
Output a total of lines.
For each round, if there exists a split that satisfies the condition, output YES; otherwise output NO.
2
5 1 2 1 2 1
7 1 2 1 1 2 1 0
NO
YES
Hint
Sample Explanation
For the first sequence, all possible split methods are:
- .
- .
- .
- .
Splitting at any position is invalid: the shorter sequence is always a subsequence of the other sequence.
For the second sequence, one valid split is
.
Constraints
This problem uses bundled testdata.
- Subtask 0 (15 points): .
- Subtask 1 (15 points): , and the testdata is generated randomly.
- Subtask 2 (30 points): is even.
- Subtask 3 (40 points): No special constraints.
For all testdata, , , , .
Translated by ChatGPT 5