302236: CF430B. Balls Game

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Balls Game

题意翻译

Lahub大佬在为AK IOI做准备,具体方法是玩一个祖玛游戏(??? 有n个球球排成一排,球球涂了不同的颜色,一共有k种颜色。一开始没有三个或以上同样颜色的球球挨在一起。 如果三个或以上同样颜色的球球挨在一起,它们就会消失掉,然后其他的球球合在一起,重复这一过程直到没有球球可以被消掉。(不理解的可以去玩一玩祖玛游戏qwq 现在Lahub大佬开始玩♂游♂戏,他有一个x色的球球准备发射。因为他复习IOI太“忙”了,所以要你求出:发射这个球球以后,能消除的最多球球数(不包括发出来的这个)。 输入:第一行n,k,x;第二行n个数表示每个球球的颜色。输出一个数表示能消除的最多球球数。

题目描述

Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are $ n $ balls put in a row. Each ball is colored in one of $ k $ colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color $ x $ . He can insert his ball at any position in the row (probably, between two other balls). If at any moment there are three or more contiguous balls of the same color in the row, they are destroyed immediately. This rule is applied multiple times, until there are no more sets of 3 or more contiguous balls of the same color. For example, if Iahub has the row of balls \[black, black, white, white, black, black\] and a white ball, he can insert the ball between two white balls. Thus three white balls are destroyed, and then four black balls become contiguous, so all four balls are destroyed. The row will not contain any ball in the end, so Iahub can destroy all 6 balls. Iahub wants to destroy as many balls as possible. You are given the description of the row of balls, and the color of Iahub's ball. Help Iahub train for the IOI by telling him the maximum number of balls from the row he can destroy.

输入输出格式

输入格式


The first line of input contains three integers: $ n $ ( $ 1<=n<=100 $ ), $ k $ ( $ 1<=k<=100 $ ) and $ x $ ( $ 1<=x<=k $ ). The next line contains $ n $ space-separated integers $ c_{1},c_{2},...,c_{n} $ ( $ 1<=c_{i}<=k $ ). Number $ c_{i} $ means that the $ i $ -th ball in the row has color $ c_{i} $ . It is guaranteed that the initial row of balls will never contain three or more contiguous balls of the same color.

输出格式


Print a single integer — the maximum number of balls Iahub can destroy.

输入输出样例

输入样例 #1

6 2 2
1 1 2 2 1 1

输出样例 #1

6

输入样例 #2

1 1 1
1

输出样例 #2

0

Input

题意翻译

Lahub大佬在为AK IOI做准备,具体方法是玩一个祖玛游戏(??? 有n个球球排成一排,球球涂了不同的颜色,一共有k种颜色。一开始没有三个或以上同样颜色的球球挨在一起。 如果三个或以上同样颜色的球球挨在一起,它们就会消失掉,然后其他的球球合在一起,重复这一过程直到没有球球可以被消掉。(不理解的可以去玩一玩祖玛游戏qwq 现在Lahub大佬开始玩♂游♂戏,他有一个x色的球球准备发射。因为他复习IOI太“忙”了,所以要你求出:发射这个球球以后,能消除的最多球球数(不包括发出来的这个)。 输入:第一行n,k,x;第二行n个数表示每个球球的颜色。输出一个数表示能消除的最多球球数。

加入题单

算法标签: