A15218 | ICPC Balloons
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $\textsf{A}$ , $\textsf{B}$ , $\textsf{C}$ , ..., $\textsf{Z}$ . You are given the order of solved problems in the contest, denoted as a string $s$ , where the $i$ -th character indicates that the problem $s_i$ 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.
- 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 $\textsf{A}$ , $\textsf{B}$ , $\textsf{C}$ , ..., $\textsf{Z}$ . You are given the order of solved problems in the contest, denoted as a string $s$ , where the $i$ -th character indicates that the problem $s_i$ 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.
输入格式
The first line of the input contains an integer $t$ ( $1 \leq t \leq 100$ ) — the number of testcases.
The first line of each test case contains an integer $n$ ( $1 \leq n \leq 50$ ) — the length of the string.
The second line of each test case contains a string $s$ of length $n$ consisting of uppercase English letters, denoting the order of solved problems.
The first line of each test case contains an integer $n$ ( $1 \leq n \leq 50$ ) — the length of the string.
The second line of each test case contains a string $s$ of length $n$ consisting of uppercase English letters, denoting the order of solved problems.
输出格式
For each test case, output a single integer — the total number of balloons that the teams received.
输入输出样例
输入 #1
6 3 ABA 1 A 3 ORZ 5 BAAAA 4 BKPT 10 CODEFORCES
输出 #1
5 2 6 7 8 17
In the first test case, $5$ balloons are given out:
- Problem $\textsf{A}$ is solved. That team receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{A}$ .
- Problem $\textsf{B}$ is solved. That team receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{B}$ .
- Problem $\textsf{A}$ is solved. That team receives only $1$ 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 $\textsf{A}$ .
The total number of balloons given out is $2+2+1=5$ .In the second test case, there is only one problem solved. The team who solved it receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{A}$ .
- Problem $\textsf{A}$ is solved. That team receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{A}$ .
- Problem $\textsf{B}$ is solved. That team receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{B}$ .
- Problem $\textsf{A}$ is solved. That team receives only $1$ 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 $\textsf{A}$ .
The total number of balloons given out is $2+2+1=5$ .In the second test case, there is only one problem solved. The team who solved it receives $2$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $\textsf{A}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted