Problem Statement
You are given a string $S$ of length $N$ consisting of lowercase English letters. Determine whether it is possible to divide $S$ into two or more consecutive substrings so that they are strictly increasing in lexicographical order.
To be precise, determine whether there is a sequence of strings $t=(t_1,t_2,\dots,t_k)$ that satisfies all of the following conditions.
- The length of the sequence
$k$is at least$2$. $t_i$is not empty. ($1 \le i \le k$)- Concatenating
$t_1,t_2,\dots,t_k$in this order results in$S$. $t_i$is lexicographically smaller than$t_{i+1}$for every integer$i$such that$1 \le i < k$.
You are given $T$ test cases. Find the answer for each of them.
What is lexicographical order? A string $S = S_1S_2\ldots S_{|S|}$ is said to be lexicographically smaller than a string $T = T_1T_2\ldots T_{|T|}$ if either 1. or 2. below holds. Here, $|S|$ and $|T|$ represent the lengths of $S$ and $T$, respectively. $|S| \lt |T|$ and $S_1S_2\ldots S_{|S|} = T_1T_2\ldots T_{|S|}$. There is an integer $1 \leq i \leq \min\lbrace |S|, |T| \rbrace$ such that both of the following hold. $S_1S_2\ldots S_{i-1} = T_1T_2\ldots T_{i-1}$. The character $S_i$ comes before $T_i$ in alphabetical order.
Constraints
$1 \le T \le 2000$$2 \le N \le 2000$$S$is a string of length$N$consisting of lowercase English letters.- The sum of
$N$over all test cases in a single input does not exceed$2000$.
Input
The input is given from Standard Input in the following format:
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
Here, $\mathrm{case}_i$ represents the $i$-th test case. Each test case is given in the following format:
N
S
Output
Print $T$ lines.
The $i$-th line $(1 \le i \le T)$ should contain Yes if it is possible to divide $S$ in the $i$-th test case into substrings that satisfy the conditions, and No otherwise.
样例
5
4
abac
3
cac
2
ab
12
abababababab
5
edcba
Yes
No
Yes
Yes
No
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。