QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100

#14694. ABB

统计

Fernando 被滑铁卢大学聘请来完成该大学前段时间启动的一个开发项目。在校园外,大学希望为重要的外宾和合作伙伴建造一条具有代表性的平房街。

目前,这条街只建了一部分,它始于湖岸,延伸至森林中,目前在那里结束。Fernando 的任务是通过在森林端建造更多的平房来完成这条街。所有现有的平房都位于街道的一侧,新的平房也应该建在同一侧。这些平房有各种类型,并涂有各种颜色。

整条街的布局在 Fernando 看来有些混乱。他担心当他加入自己设计的新平房时,会显得更加混乱。为了抵消所有平房形状带来的混乱感,他希望通过为新平房选择合适的颜色来为这种排列增添一些秩序。当项目完成时,整个平房颜色序列将是对称的,也就是说,从街道的任一端观察,颜色序列都是相同的。

在其他问题中,Fernando 想知道,在遵守他自己设定的平房颜色约束(即对称性)的同时,他最少需要建造并涂装多少个新平房才能完成该项目。

输入格式

第一行包含一个整数 $N$($1 \le N \le 4 \cdot 10^5$),表示街道上现有平房的数量。

第二行描述了现有平房的颜色序列,从湖岸边的街道起点开始。该行包含一个由 $N$ 个小写字母(az)组成的字符串,其中不同的字母代表不同的颜色。

输出格式

输出必须添加到街道森林端并进行适当涂装以满足 Fernando 颜色对称性要求的最小平房数量。

样例

样例输入 1

3
abb

样例输出 1

1

样例输入 2

12
recakjenecep

样例输出 2

11

样例输入 3

15
murderforajarof

样例输出 3

6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.