A. Short Sort

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are three cards with letters aa, bb, cc 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 abcabc after the operation? Output "YES" if it is possible, and "NO" otherwise.

Input

The first line contains a single integer t� (1≤t≤61≤�≤6) --- the number of test cases.

The only line of each test case contains a single string consisting of each of the three characters aa, bb, and cc exactly once, representing the cards.

Output

For each test case, output "YES" if you can make the row abcabc 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).

Example

input

Copy

复制代码

6

abc

acb

bac

bca

cab

cba

output

Copy

复制代码
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 abcabc.

In the second test case, we can swap cc and bb: acb→abcacb→abc.

In the third test case, we can swap bb and aa: bac→abcbac→abc.

In the fourth test case, it is impossible to make abcabc using at most one operation.

解题说明:水题,三个字母只要确保有一个在正确的位置上就行。

cpp 复制代码
#include <stdio.h>
int main()
{
	int n;
	char a[4];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", a);
		if (a[0] == 'a' || a[1] == 'b' || a[2] == 'c')
		{
			printf("YES\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}
相关推荐
bjbxkj5 分钟前
Profinet转Ethernet IP主站网关:点燃氢醌生产线的智慧之光!
java·网络·tcp/ip
exe45213 分钟前
力扣每日一题5-19
java·算法·leetcode
冷yan~14 分钟前
构建下一代AI智能体:基于Spring AI的多轮对话应用
java·人工智能·spring·ai
?abc!15 分钟前
spring框架中的本地缓存:spring cache基本使用
java·spring·缓存
fouen16 分钟前
【语义分割专栏】先导篇:评价指标(PA,CPA,IoU,mIoU,FWIoU,F1)
人工智能·算法·机器学习·计算机视觉
ABCDEEE720 分钟前
SpringAI
java
zbh060437 分钟前
AcWing 223. 阿九大战朱最学——扩展欧几里得算法
算法
charlie11451419138 分钟前
Linux内核深入学习(4)——内核常见的数据结构2——红黑树
linux·数据结构·学习·红黑树
不穿铠甲的穿山甲44 分钟前
mysql-Java手写分布式事物提交流程
java·分布式·mysql
mochensage1 小时前
2025年全国青少年信息素养大赛C++小学全年级初赛试题
开发语言·c++·算法