408489: GYM103150 C EZPC Sort

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. EZPC Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a rearrangement of the string abcdefghijklmnopqrstuvwxyz. Call it $$$s$$$. You can perform the following operation on $$$s$$$ as many times as you want:

  • Sort any substring of $$$s$$$ in increasing order. (Recall that $$$a$$$ is a substring of $$$b$$$ if $$$a$$$ can be obtained by deleting some (possibly zero) characters from the beginning and end of $$$b$$$.)

The string is called easy if you can delete some of the characters in $$$s$$$ to make $$$s$$$ equal to the string ezpc. Is it possible to make $$$s$$$ easy after some (possibly zero) operations?

Input

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5000$$$) — the number of test cases.

The only line of each test case consists of a single string $$$s$$$ — the initial string. $$$s$$$ is a rearrangement of the string abcdefghijklmnopqrstuvwxyz.

Output

For each test case, output YES if it is possible to make $$$s$$$ easy after some (possibly zero) operations. Otherwise, output NO.

ExampleInput
3
ezpcabdfghijklmnoqrstuvwxy
zaepbcdfghijklmnoqrstuvwxy
orzgvlkbenwyqjmdfsctxhiaup
Output
YES
YES
NO
Note

In the first test case, $$$s$$$ is already easy (so you don't need to perform any operations). You can delete the last $$$22$$$ characters of $$$s$$$, and you will be left with the string ezpc.

In the second test case, you can make $$$s$$$ easy with one operation: zaepcbdefgh... $$$\rightarrow$$$ aezpbcdefgh....

Now, you can delete the first character, the fourth character, and the last $$$20$$$ characters in $$$s$$$ to make the string ezpc: _ezp_c___.... Here the deleted letters are represented with _.

It can be shown that it is impossible to make the string in the third test case easy.

加入题单

上一题 下一题 算法标签: