A15514 | Atilla's Favorite Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In order to write a string, Atilla needs to first learn all letters that are contained in the string.
Atilla needs to write a message which can be represented as a string $s$ . He asks you what is the minimum alphabet size required so that one can write this message.
The alphabet of size $x$ ( $1 \leq x \leq 26$ ) contains only the first $x$ Latin letters. For example an alphabet of size $4$ contains only the characters $\texttt{a}$ , $\texttt{b}$ , $\texttt{c}$ and $\texttt{d}$ .
Atilla needs to write a message which can be represented as a string $s$ . He asks you what is the minimum alphabet size required so that one can write this message.
The alphabet of size $x$ ( $1 \leq x \leq 26$ ) contains only the first $x$ Latin letters. For example an alphabet of size $4$ contains only the characters $\texttt{a}$ , $\texttt{b}$ , $\texttt{c}$ and $\texttt{d}$ .
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases.
The first line of each test case contains a single integer $n$ ( $1 \leq n \leq 100$ ) — the length of the string.
The second line of each test case contains a string $s$ of length $n$ , consisting of lowercase Latin letters.
The first line of each test case contains a single integer $n$ ( $1 \leq n \leq 100$ ) — the length of the string.
The second line of each test case contains a string $s$ of length $n$ , consisting of lowercase Latin letters.
输出格式
For each test case, output a single integer — the minimum alphabet size required to so that Atilla can write his message $s$ .
输入输出样例
输入 #1
5 1 a 4 down 10 codeforces 3 bcf 5 zzzzz
输出 #1
1 23 19 6 26
For the first test case, Atilla needs to know only the character $\texttt{a}$ , so the alphabet of size $1$ which only contains $\texttt{a}$ is enough.
For the second test case, Atilla needs to know the characters $\texttt{d}$ , $\texttt{o}$ , $\texttt{w}$ , $\texttt{n}$ . The smallest alphabet size that contains all of them is $23$ (such alphabet can be represented as the string $\texttt{abcdefghijklmnopqrstuvw}$ ).
For the second test case, Atilla needs to know the characters $\texttt{d}$ , $\texttt{o}$ , $\texttt{w}$ , $\texttt{n}$ . The smallest alphabet size that contains all of them is $23$ (such alphabet can be represented as the string $\texttt{abcdefghijklmnopqrstuvw}$ ).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted