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;
}
相关推荐
资深低代码开发平台专家7 分钟前
通用编程时代正在向专用化分层演进
java·大数据·c语言·c++·python
开心香辣派小星9 分钟前
23种设计模式-17备忘录模式
java·设计模式·备忘录模式
TL滕10 分钟前
从0开始学算法——第六天(进阶排序算法)
笔记·学习·算法·排序算法
TL滕14 分钟前
从0开始学算法——第六天(进阶排序算法练习)
笔记·python·学习·算法·排序算法
q_191328469516 分钟前
基于SpringBoot2+Vue2+uniapp的考研社区论坛网站及小程序
java·vue.js·spring boot·后端·小程序·uni-app·毕业设计
課代表21 分钟前
正弦函数与椭圆的关系
数学·算法·几何·三角函数·椭圆·正弦·周长
zl_vslam24 分钟前
SLAM中的非线性优-3D图优化之相对位姿Between Factor(七)
人工智能·算法·计算机视觉·3d
CoderYanger24 分钟前
动态规划算法-简单多状态dp问题:12.打家劫舍Ⅱ
开发语言·算法·leetcode·职场和发展·动态规划·1024程序员节
源码技术栈25 分钟前
Java智能诊所管理系统源码 SaaS云门诊运维平台源码
java·大数据·运维·人工智能·源码·诊所·门诊
一水鉴天26 分钟前
专题讨论 类型理论和范畴理论之间的关系:闭关系/闭类型/闭范畴 与 计算式(ima.copilot)
开发语言·算法·架构