310699: CF1873A. Short Sort

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

Description

A. Short Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

There are three cards with letters $\texttt{a}$, $\texttt{b}$, $\texttt{c}$ placed in a row in some order. You can do the following operation at most once:

  • Pick two cards, and swap them.
Is it possible that the row becomes $\texttt{abc}$ after the operation? Output "YES" if it is possible, and "NO" otherwise.Input

The first line contains a single integer $t$ ($1 \leq t \leq 6$) — the number of test cases.

The only line of each test case contains a single string consisting of each of the three characters $\texttt{a}$, $\texttt{b}$, and $\texttt{c}$ exactly once, representing the cards.

Output

For each test case, output "YES" if you can make the row $\texttt{abc}$ with at most one operation, or "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

ExampleInput
6
abc
acb
bac
bca
cab
cba
Output
YES
YES
YES
NO
NO
YES
Note

In the first test case, we don't need to do any operations, since the row is already $\texttt{abc}$.

In the second test case, we can swap $\texttt{c}$ and $\texttt{b}$: $\texttt{acb} \to \texttt{abc}$.

In the third test case, we can swap $\texttt{b}$ and $\texttt{a}$: $\texttt{bac} \to \texttt{abc}$.

In the fourth test case, it is impossible to make $\texttt{abc}$ using at most one operation.

Output

题目大意:
题目名为 "Short Sort",有一个由字母 'a'、'b'、'c' 组成的序列,你可以至多进行一次交换两个字母的操作,问是否能通过这个操作得到序列 "abc"。如果能,输出 "YES",否则输出 "NO"。

输入输出数据格式:
输入:
- 第一行是一个整数 t (1 ≤ t ≤ 6),表示测试案例的数量。
- 每个测试案例占一行,包含三个由 'a'、'b'、'c' 组成的字符串,每个字母恰好出现一次。

输出:
- 对于每个测试案例,如果能通过至多一次交换得到 "abc",则输出 "YES",否则输出 "NO"。
- 答案的输出格式不敏感,即 "yEs"、"yes"、"Yes" 和 "YES" 都会被视为肯定回答。

示例:
输入:
```
6
abc
acb
bac
bca
cab
cba
```
输出:
```
YES
YES
YES
NO
NO
YES
```

注意:
- 在第一个测试案例中,不需要进行任何操作,因为序列已经是 "abc"。
- 在第二个测试案例中,可以交换 'c' 和 'b': "acb" → "abc"。
- 在第三个测试案例中,可以交换 'b' 和 'a': "bac" → "abc"。
- 在第四个测试案例中,无法通过至多一次操作得到 "abc"。题目大意: 题目名为 "Short Sort",有一个由字母 'a'、'b'、'c' 组成的序列,你可以至多进行一次交换两个字母的操作,问是否能通过这个操作得到序列 "abc"。如果能,输出 "YES",否则输出 "NO"。 输入输出数据格式: 输入: - 第一行是一个整数 t (1 ≤ t ≤ 6),表示测试案例的数量。 - 每个测试案例占一行,包含三个由 'a'、'b'、'c' 组成的字符串,每个字母恰好出现一次。 输出: - 对于每个测试案例,如果能通过至多一次交换得到 "abc",则输出 "YES",否则输出 "NO"。 - 答案的输出格式不敏感,即 "yEs"、"yes"、"Yes" 和 "YES" 都会被视为肯定回答。 示例: 输入: ``` 6 abc acb bac bca cab cba ``` 输出: ``` YES YES YES NO NO YES ``` 注意: - 在第一个测试案例中,不需要进行任何操作,因为序列已经是 "abc"。 - 在第二个测试案例中,可以交换 'c' 和 'b': "acb" → "abc"。 - 在第三个测试案例中,可以交换 'b' 和 'a': "bac" → "abc"。 - 在第四个测试案例中,无法通过至多一次操作得到 "abc"。

加入题单

算法标签: