No.3644 Division by Shitoshitoto Sequence
タグ : / 解いたユーザー数 37
作問者 :
kazuppa
/ テスター :
Problem Statement
A sequence $X$ satisfying the following conditions is defined as a Shitoshitoto sequence.
- $|X|=5$
- $X_1=X_3$
- $X_2=X_4=X_5$
- $X_1\neq X_2$
You are given a sequence of positive integers $(A_1,A_2,...,A_{5N})$ of length $5N$. Determine whether there exists a way to divide $A$ into $N$ contiguous subsequences such that all of the subsequences are Shitoshitoto sequences.
You are given $T$ test cases; answer all of them.
Constraints
- $1\leq T\leq 10^5$
- $1\leq N\leq 10^5$
- The sum of $N$ over all test cases is at most $10^5$
- $1\leq A_i\leq 10^9$
- All input values are integers
Subtasks
This problem has partial scoring by subtasks.
| Subtask Name | Score | Constraints |
|---|---|---|
| Subtask 1 | 10 % | $N=1$ |
| Subtask 2 | 20 % | $N=2$ |
| Subtask 3 | 70 % | No additional constraints |
Input
$T$
$\text{case}_{1}$
$\text{case}_{2}$
$\vdots$
$\text{case}_{T}$
Each test case is given in the following format.
$N$
$A_1\ A_2\ \dotsc\ A_{5N}$
Output
Print $T$ lines.
On the $i$-th line, for test case $i$, print Yes if there exists a way satisfying the conditions of the problem statement, and No otherwise.
Sample
Sample 1
Input
3 2 1 5 1 5 5 6 5 6 5 5 1 1 1 1 1 1 3 3 3 3 4 4 4 3 3 3 4 4 4 4 4 4
Output
Yes No No
For the $1$st test case, for example, dividing $A$ into $(1,5,1,5,5)$ and $(6,5,6,5,5)$ satisfies the conditions, since both of them are Shitoshitoto sequences.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。