CF1760B.Atilla's Favorite Problem

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ss. He asks you what is the minimum alphabet size required so that one can write this message.

The alphabet of size xx (1≤x≤261 \leq x \leq 26) contains only the first xx Latin letters. For example an alphabet of size 44 contains only the characters a\texttt{a}, b\texttt{b}, c\texttt{c} and d\texttt{d}.

为了书写一个字符串,阿提拉需要首先学会该字符串中包含的所有字母。

阿提拉需要书写一条可表示为字符串 ss 的消息。他向你询问:能够书写该消息所需的最小字母表大小是多少?

大小为 xx(1≤x≤261 \leq x \leq 26)的字母表仅包含前 xx 个拉丁字母。例如,大小为 44 的字母表仅包含字符 a\texttt{a}、b\texttt{b}、c\texttt{c} 和 d\texttt{d}。

输入格式

The first line contains a single integer tt (1≤t≤10001 \leq t \leq 1000) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1001 \leq n \leq 100) — the length of the string.

The second line of each test case contains a string ss of length nn, consisting of lowercase Latin letters.

第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)—— 字符串的长度。

每个测试用例的第二行包含一个长度为 nn 的字符串 ss,由小写拉丁字母组成。

输出格式

For each test case, output a single integer — the minimum alphabet size required to so that Atilla can write his message ss.

对于每个测试用例,输出一个整数——Atilla 能够写出消息 ss 所需的最小字母表大小。

输入输出样例

  • 输入#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 a\texttt{a}, so the alphabet of size 11 which only contains a\texttt{a} is enough.

For the second test case, Atilla needs to know the characters d\texttt{d}, o\texttt{o}, w\texttt{w}, n\texttt{n}. The smallest alphabet size that contains all of them is 2323 (such alphabet can be represented as the string abcdefghijklmnopqrstuvw\texttt{abcdefghijklmnopqrstuvw}).

对于第一个测试用例,Atilla 只需知道字符 a\texttt{a},因此仅包含 a\texttt{a} 的大小为 11 的字母表就已足够。

对于第二个测试用例,Atilla 需要知道字符 d\texttt{d}、o\texttt{o}、w\texttt{w}、n\texttt{n}。包含所有这些字符的最小字母表大小为 2323(这样的字母表可表示为字符串 abcdefghijklmnopqrstuvw\texttt{abcdefghijklmnopqrstuvw})。

输入解题思路,AI测评打分。不知道怎么写?

首页