欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1703B.ICPC Balloons
ICPC Balloons
In an ICPC contest, balloons are distributed as follows:
- Whenever a team solves a problem, that team gets a balloon.
- The first team to solve a problem gets an additional balloon.
A contest has 26 problems, labelled , , , ..., . You are given the order of solved problems in the contest, denoted as a string , where the -th character indicates that the problem has been solved by some team. No team will solve the same problem twice.
Determine the total number of balloons that the teams received. Note that some problems may be solved by none of the teams.
Input
The first line of the input contains an integer () — the number of testcases.
The first line of each test case contains an integer () — the length of the string.
The second line of each test case contains a string of length consisting of uppercase English letters, denoting the order of solved problems.
Output
For each test case, output a single integer — the total number of balloons that the teams received.
Note
In the first test case, balloons are given out:
- Problem is solved. That team receives balloons: one because they solved the problem, an an additional one because they are the first team to solve problem .
- Problem is solved. That team receives balloons: one because they solved the problem, an an additional one because they are the first team to solve problem .
- Problem is solved. That team receives only balloon, because they solved the problem. Note that they don't get an additional balloon because they are not the first team to solve problem .
The total number of balloons given out is .
In the second test case, there is only one problem solved. The team who solved it receives balloons: one because they solved the problem, an an additional one because they are the first team to solve problem .
Samples
6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES
5
2
6
7
8
17
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |