QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#6180. 滚动雪人游戏问题

الإحصائيات

在滚动雪人游戏中,已经堆好了 $n$ 个不同类型的雪人。这些雪人共有 $A$, $B$, $C$ 三种不同的类型。滚动雪人游戏的规则是,在当前的雪人队列中,任意选择 $2$ 个不同类型的雪人,将他们合并改造成与合并前的 $2$ 种类型不同类型的一个新的雪人。例如,选择了 $2$ 个不同类型的雪人,它们的类型分别为 $A$ 和 $B$,则合并改造后的新的雪人的类型为 $C$。选择类型分别为 $A$ 和 $C$,则合并改造后的类型为 $B$;选择类型分别为 $B$ 和 $C$,则合并改造后的类型为 $A$。当雪人队列中只剩下同一种类型的雪人时,游戏结束。小明和小雪希望用最少的合并次数完成滚动雪人游戏。

滚动雪人游戏问题:对于给定的雪人队列,计算出用最少的合并次数完成滚动雪人游戏后,留在在雪人队列中的雪人类型。

输入格式

每个测试项有多组测试数据。每组测试数据的第一行有一个正整数 $n$,第二行是一个由大写英文字母 A, B, C 组成的,长度为 $n$ 的字符串,表示初始雪人队列。

输出格式

对每组测试数据,依次输出对于给定的初始雪人队列,用最少的合并次数完成滚动雪人游戏后,留在在雪人队列中的雪人类型 A, BC。如果不能确定最终的雪人类型,则输出大写英文字母 N

样例数据

样例输入

5
ABCCC
3
ABC

样例输出

C
N

子任务

测试数据中 $20\%$ 的数据满足 $n \leq 1\,000$。

测试数据中 $100\%$ 的数据满足 $n \leq 10\,000$。


  1. 赛时并未提供数据组数,“请选手自行评估”。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.