Codeforces Round #619 (Div. 2) A. Three Strings
You are given three strings aa , bb and cc of the same length nn . The strings consist of lowercase English letters only. The ii -th letter of aa is aiai , the ii -th letter of bb is bibi , the ii -th letter of cc is cici .
For every ii (1≤i≤n1≤i≤n ) you must swap (i.e. exchange) cici with either aiai or bibi . So in total you'll perform exactly nn swap operations, each of them either ci↔aici↔ai or ci↔bici↔bi (ii iterates over all integers between 11 and nn , inclusive).
For example, if aa is "code", bb is "true", and cc is "help", you can make cc equal to "crue" taking the 11 -st and the 44 -th letters from aa and the others from bb . In this way aa becomes "hodp" and bb becomes "tele".
Is it possible that after these swaps the string aa becomes exactly the same as the string bb ?
Input
The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤1001≤t≤100 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a string of lowercase English letters aa .
The second line of each test case contains a string of lowercase English letters bb .
The third line of each test case contains a string of lowercase English letters cc .
It is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding 100100 .
Output
Print tt lines with answers for all test cases. For each test case:
If it is possible to make string aa equal to string bb print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print either lowercase or uppercase letters in the answers.
Example
4
aaa
bbb
ccc
abc
bca
bca
aabb
bbaa
baba
imi
mii
iim
NO
YES
YES
NO
水题。最终目的是要求a和b一样,这样的话,因为ai或者bi其中之一可以与ci交换,所以如果ai==ci,那么拿bi与ci交换,之后可以得到ai==bi;同理bi==ci,可以拿ai与ci交换,遍历一遍看看能不能满足即可。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
char a[];
char b[];
char c[];
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
int i;
int cnt=;
for(i=;i<strlen(a);i++)
{
if(a[i]==c[i]||b[i]==c[i])cnt++;
}
if(cnt==strlen(a))
{
cout<<"YES"<<endl;
continue;
}
cout<<"NO"<<endl;
}
}
最新文章
- Linux学习之八--关闭firewall防火墙安装iptables并配置
- eclipse项目自动发布到tomcat目录,缺文件。
- high-frequency words and phases
- Human Gene Functions
- Welcome to MacJournal!
- [原创] 初识Agile/CMMI/Scrum
- Unity3D脚本中文系列教程(十六)
- ldd获得可执行程序的所有库并输出到指定目录
- iOS程序员的React Native开发工具集
- Spring MVC 过滤静态资源访问
- python: c_char_p指向的bitmap图像数据,通过c_char_Array最终赋值给PIL的Image对象
- eclipse经常出现——未响应!!!
- .npy,.mat,.txt转换
- Weblogic CVE-2018-2894 漏洞复现
- ejb 和pojo , jboss 和 tomcat
- SpringMVC中异常捕获
- Python基础学习总结(五)
- jenkins 学习记录2
- cdq分治略解
- DNN优势
热门文章
- 牛客多校第三场F Planting Trees 单调栈
- angular 读写电脑本地文件
- Linux(Ubuntu)服务器是否安装ssh,使用xshell远程连接
- mvc:annotation-driven的前缀 ";mvc";未绑定
- jmeter+influxdb+granfana+collectd监控cpu+mem+TPS
- 解决Hbase启动后,hmaster会在几秒钟后自动关闭(停掉)!!!
- Mysql sql语句技巧与优化
- tomcat查看当前内存
- 【StarUML】组件图
- redis哈希操作