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
Input
4
aaa
bbb
ccc
abc
bca
bca
aabb
bbaa
baba
imi
mii
iim
Output
NO
YES
YES
NO
Note
In the first test case, it is impossible to do the swaps so that string aa becomes exactly the same as string bb.

In the second test case, you should swap cici with aiai for all possible ii. After the swaps aa becomes “bca”, bb becomes “bca” and cc becomes “abc”. Here the strings aa and bb are equal.

In the third test case, you should swap c1c1 with a1a1, c2c2 with b2b2, c3c3 with b3b3 and c4c4 with a4a4. Then string aa becomes “baba”, string bb becomes “baba” and string cc becomes “abab”. Here the strings aa and bb are equal.

In the fourth test case, it is impossible to do the swaps so that string aa becomes exactly the same as string bb.
水题。
代码如下:

#include<bits/stdc++.h>
#define ll long long
using namespace std;string a,b,c;int main()
{int t;scanf("%d",&t);while(t--){cin>>a>>b>>c;int n=a.length();int flag=1;for(int i=0;i<n&&flag;i++){if(a[i]!=b[i]){if(a[i]==c[i]) continue;else if(b[i]==c[i]) continue;else flag=0;}else{if(a[i]!=c[i]) flag=0;}}if(flag) cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}

努力加油a啊,(o)/~

Three Strings CodeForces - 1301A相关推荐

  1. 【CodeForces - 798A】Mike and palindrome (回文串,水题,字符串问题)

    题干: Mike has a string s consisting of only lowercase English letters. He wants to change exactly one ...

  2. Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训

    Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训 导语 涉及的知识点 题目 A Game B ...

  3. Educational Codeforces Round 12 C. Simple Strings 贪心

    C. Simple Strings 题目连接: http://www.codeforces.com/contest/665/problem/C Description zscoder loves si ...

  4. Codeforces Round #313 (Div. 1) B. Equivalent Strings

    Equivalent Strings Problem's Link:   http://codeforces.com/contest/559/problem/B  Mean: 给定两个等长串s1,s2 ...

  5. Codeforces Round #598 (Div. 3) F. Equalizing Two Strings 思维 + 逆序对

    传送门 文章目录 题意: 思路: 题意: 给你两个长度为nnn的串a,ba,ba,b,每次可以同时翻转a,ba,ba,b中任意一段长度为L(1≤L≤n)L(1\le L\le n)L(1≤L≤n)的子 ...

  6. CodeForces - 798B Mike and strings

    B. Mike and strings time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...

  7. Codeforces - Reachable Strings

    题目链接:Codeforces - Reachable Strings 我们可以发现每次0的移动都是不改变当前0的位置的左右1的奇偶性. 并且0是不可能改变相对位置的,所以我们对0的个数以及位置的左边 ...

  8. codeforces 616F Expensive Strings

    codeforces 616F Expensive Strings (广义后缀自动机) https://codeforces.com/contest/616/problem/F 题意: 给你n个字符串 ...

  9. C. Tyler and Strings(组合数学,树状数组维护前缀和)(Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad i)

    对我来说比较困难的一题了,尝试着自己写了一下,调不出来遂放弃. Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad in Info ...

最新文章

  1. 梯度中心化,一行代码加速训练并提升泛化能力
  2. Office 2003出现发送错误报告怎么办
  3. Django--视图函数
  4. 分页请求json数据_pyspider抓取虎嗅网文章数据
  5. 安装mysql 图_如何在Windows下安装MYSQL,并截图说明
  6. 新建sublime 的python代码文件时自动在头部增加几行常用代码
  7. linux源码包编译安装与rpm安装方法介绍
  8. PHP调试环境搭建的一些常见问题
  9. 软件测试的缺陷管理系统有哪些,简述:一款优秀的缺陷管理系统有哪些功能特点!...
  10. 花器官身份基因与靶基因间的调控进化情况
  11. 中国双门和多门冰箱市场趋势报告、技术动态创新及市场预测
  12. struts2 标签单选框_Struts 2 UI标签–表单,复选框,单选,选择,提交
  13. Mac中必不可少的软件——Tuxera NTFS
  14. python实现Kruskal算法求解加权图中最小生成树问题
  15. 双击计算机找不到应用程序,WIN7下双击光驱打不开,提示找不到应用程序,右键
  16. R语言差异检验:非参数检验
  17. 【Python】使用torrentParser1.03对单文件torrent的分析结果
  18. 关于JAVAFX的鼠标单击事件案例
  19. Unity 球面行走
  20. perl脚本提取后仿中的notimingcheck路径

热门文章

  1. swift5导航栏标题文字属性设置
  2. C语言编写工资管理系统类似学生管理系统
  3. 浙大计算机系学霸,国内三个“图灵班”,学霸中的尖子才能考得上,全是计算机人才!...
  4. linux通过html显示图片,如何在Linux上将HTML页面转化成Png图片?
  5. was服务器里面jar包_was8.5.5.9项目部署失败,出现mybatis的jar包异常
  6. Android开发之ApiCloud轮播图开发
  7. java 图片请求_java请求C++客户端上传图片
  8. matlab 设计 18db,基于混沌理论的微弱MPSK信号解调方案设计
  9. APPium-Xpath,swipe练习
  10. Golang 推荐的命名规范