問題一覧 > 通常問題

No.3644 Division by Shitoshitoto Sequence

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 37
作問者 : kazuppa / テスター : Tamiji153 Unbakedbread
お気に入りにしたユーザー ProblemId : 13637 / 自分の提出
問題文最終更新日: 2026-08-25 18:38:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Paken新入生コンday2 (順位表) の他の問題:

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 110 %$N=1$
Subtask 220 %$N=2$
Subtask 370 %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もしくは右上の雲マークをクリックしてアカウントを作成してください。