AtCoder Beginner Contest 206(Sponsored by Panasonic)
D
KAIBUNsyo
AtCoder
⌀ 879
原题
← CE →
翻译中…

Problem Statement

翻译中…

You are given a sequence of $N$ positive integers: $A=(A_1,A_2, \dots A_N)$. You can do the operation below zero or more times. At least how many operations are needed to make $A$ a palindrome?

翻译中…
  • Choose a pair $(x,y)$ of positive integers, and replace every occurrence of $x$ in $A$ with $y$.
翻译中…

Here, we say $A$ is a palindrome if and only if $A_i=A_{N+1-i}$ holds for every $i$ ($1 \le i \le N$).

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \le N \le 2 \times 10^5$
  • $1 \le A_i \le 2 \times 10^5$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \dots A_N

翻译中…

Output

翻译中…

Print the answer as an integer.

翻译中…

样例

Input #1
8
1 5 3 2 5 2 3 1
Output #1
2
- Initially, we have $A=(1,5,3,2,5,2,3,1)$. - After replacing every occurrence of $3$ in $A$ with $2$, we have $A=(1,5,2,2,5,2,2,1)$. - After replacing every occurrence of $2$ in $A$ with $5$, we have $A=(1,5,5,5,5,5,5,1)$. In this way, we can make $A$ a palindrome in two operations, which is the minimum needed.
Input #2
7
1 2 3 4 1 2 3
Output #2
1
Input #3
1
200000
Output #3
0
$A$ may already be a palindrome in the beginning.
题目信息
题号
abc206_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。