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;
}
相关推荐
lifallen15 分钟前
从Apache Doris 学习 HyperLogLog
java·大数据·数据仓库·算法·apache
fire-flyer15 分钟前
maven-jlink-plugin入门
java·maven
Knight_AL17 分钟前
Java 单元测试全攻略:JUnit 生命周期、覆盖率提升、自动化框架与 Mock 技术
java·junit·单元测试
cominglately22 分钟前
记录一次生产环境数据库死锁的处理过程
java·死锁
用户03321266636725 分钟前
在 Word 文档中插入图片的 Java 指南
java
深圳蔓延科技32 分钟前
单点登录到底是什么?
java·后端
SimonKing34 分钟前
除了 ${},Thymeleaf 的这些用法让你直呼内行
java·后端·程序员
智驱力人工智能40 分钟前
使用手机检测的智能视觉分析技术与应用 加油站使用手机 玩手机检测
深度学习·算法·目标检测·智能手机·视觉检测·边缘计算
科兴第一吴彦祖1 小时前
基于Spring Boot + Vue 3的乡村振兴综合服务平台
java·vue.js·人工智能·spring boot·推荐算法
ajassi20001 小时前
开源 java android app 开发(十八)最新编译器Android Studio 2025.1.3.7
android·java·开源