問題一覧 > 通常問題

No.3286 Make a Happy Connection

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 120
作問者 : kona0001 / テスター : tobisatis RyosukeFukatani koba-e964 ir5 drken1215
お気に入りにしたユーザー ProblemId : 12629 / 自分の提出
問題文最終更新日: 2025-09-24 00:45:39
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
yukicoder contest 485 (順位表) の他の問題:

Problem Statement

yuki feels happy when equal values appear next to each other in a sequence.

You are given a sequence $A$ consisting of $N$ elements. Determine whether, by swapping adjacent elements of $A$ exactly $1$ time, you can make at least $1$ place where adjacent elements have the same value.

More formally, you perform the following operation exactly $1$ time.

  • Choose any $i$ $(1 \le i \le N-1)$ and swap $A_i,A_{i+1}$.

Considering $j$ such that $1 \le j \le N-1$, determine whether you can make it so that, after the operation, there exists $j$ such that $A_j = A_{j+1}$.

Constraints

  • $2 \le N \le 500$
  • $1 \le A_i \le 100$
  • All inputs are integers.

Input

The input is given from standard input in the following format.

$N$
$A_1\ A_2\ \cdots\ A_N$

Output

Print Yes if the condition is satisfied, and No otherwise. Print a newline at the end.

Sample

Sample 1
Input
4
1 3 2 3
Output
Yes

Performing the operation with $i=3$ swaps $A_3 $ and $A_4$, resulting in $A=(1,3,3,2)$. Here $A_2=3$, $A_3=3$, so equal elements are next to each other and the condition is satisfied.

Sample 2
Input
5
1 1 1 1 1
Output
Yes

The condition is satisfied no matter how you perform the operation.

Sample 3
Input
5
1 2 3 4 1
Output
No

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。