306059: CF1140B. Good String
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Good String
题意翻译
### 题目描述 有一个长度为$n(1<=n<=100)$的字符串,只由<,>两种字符组成。对其进行一次操作如下: ------------ 如果选择一个>字符,这个字符**右面**的那一个字符会被删除。特别地,如果你选择的这个字符>位于字符串的最右侧,什么都不会发生。同理,如果选择一个<字符,这个字符**左面**的那一个字符会被删除,选择位于字符串最左边的<字符也什么都不会发生。 ------------ 定义一下的一个字符串是“好的”:经过若干次以上操作,这个字符串可以只含有一种字符,如>,>>等。 在执行操作之前,你可以删去字符串中的$k(0<=k<=n-1)$$个字符。注意不可以把整个字符串都删去了。 你需要找出$k$的最小值,使得删去$k$个字符后的字符串是“好的”。 ### 输入格式 第一行包含一个整数$t(1<=t<=100)$,表示测试数据的组数。 接下来有$2t$行,每$2$行表示一组数据: 第$i$组数据的第一行是一个整数$n$,表示字符串长度; 第二行是一个只含有字符<和>的字符串$s$。 ### 输出格式 输出共$t$行,每行包含一个整数,表示删去字符数量的最小值,使剩下的字符串是“好的”。 ### 输入输出样例 输入: ```cpp 3 2 <> 3 ><< 1 > ``` 输出: ```cpp 1 0 0 ``` ### 样例说明 第一组数据中,删除任意一个字符都可以使得剩下的字符串是“好的”。 第二组数据中,原字符串就是“好的”,无需删除任何字符。题目描述
You have a string $ s $ of length $ n $ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens). For example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <. The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $ n - 1 $ , but not the whole string). You need to calculate the minimum number of characters to be deleted from string $ s $ so that it becomes good.输入输出格式
输入格式
The first line contains one integer $ t $ ( $ 1 \le t \le 100 $ ) – the number of test cases. Each test case is represented by two lines. The first line of $ i $ -th test case contains one integer $ n $ ( $ 1 \le n \le 100 $ ) – the length of string $ s $ . The second line of $ i $ -th test case contains string $ s $ , consisting of only characters > and <.
输出格式
For each test case print one line. For $ i $ -th test case print the minimum number of characters to be deleted from string $ s $ so that it becomes good.
输入输出样例
输入样例 #1
3
2
<>
3
><<
1
>
输出样例 #1
1
0
0