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;
}
}
Codeforces Round #619 (Div. 2) A. Three Strings的更多相关文章
- Codeforces Round #313 (Div. 1) B. Equivalent Strings
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
- Codeforces Round #313 (Div. 2) D. Equivalent Strings
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...
- Codeforces Round #302 (Div. 1) C. Remembering Strings DP
C. Remembering Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces Round #302 (Div. 1) C - Remembering Strings 状压dp
C - Remembering Strings 思路:最关键的一点是字符的个数比串的个数多. 然后就能状压啦. #include<bits/stdc++.h> #define LL lon ...
- (原创)Codeforces Round #550 (Div. 3) A Diverse Strings
A. Diverse Strings time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)
D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #619 (Div. 2) Ayoub's function
Ayoub thinks that he is a very smart person, so he created a function f(s)f(s) , where ss is a binar ...
- Codeforces Round #619 (Div. 2)
A. Three Strings 题意:给三个长度相同的非空字符串abc,依次将c中的每个字符和a或者b中对应位置的字符进行交换,交换必须进行,问能否使得ab相同. 思路:对于每一个位置,如果三个字符 ...
随机推荐
- 牛客网刷题总结—Day1
1.关于哈夫曼树 哈夫曼树也称最优二叉树,其n个叶子节点都是带有权值的,其节点的带权路径长度(n个叶子节点的权值*其到根节点的路径之和)最小的二叉树即为哈夫曼树. 一般的哈夫曼树不存在度为1的节点(除 ...
- Permission denied 解决办法
Permission denied 解决的办法: $ sudo chmod -R 777 某一目录 其中-R 是指级联应用到目录里的所有子目录和文件777 是所有用户都拥有最高权限
- halo的工作目录,有一个是在代码里配置的,硬编码了
在HaloProperties.java中: /** * Work directory. */private String workDir = HaloConst.USER_HOME + " ...
- Atcoder Beginner Contest151E(排列组合)
排列组合 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ; ]; long lo ...
- GIL/Copy/私有/面向对象
1. GIL Python语言和GIL没有关系.仅仅是由于历史原因在Cpython虚拟机(解释器),难以移除GIL. GIL:全局解释器锁.每个线程在执行的过程都需要先获取GIL,保证同一时刻只有一个 ...
- 连接查询:inner join,left join,right join
感谢原创:https://blog.csdn.net/plg17/article/details/78758593 准备工作: 1)新建两张表a_table和b_table: create table ...
- 面向对象--OO--object-oriented
如何把大象装冰箱? 面向过程:打开冰箱门---把大象装进去---关上冰箱门 面向对象: 1.大象:进入冰箱.离开冰箱 2.冰箱:开门.关门 3.人:检测1.检测2 面向对象三大特性:封装.继承.多态 ...
- IDEA 自定义注释模板 支持设置多个param参数
在使用IDEA过程中,很多人可能感觉自带注释太简约了,想增加一些属性,比如作者.创建时间.版本号等等,这个时候我们可以使用自定义的注释模板来实现我们需求,话不多说直接进入如何自定义模板设置: 打开设置 ...
- 使用dockerfile构建镜像并在容器中安装软件遇到的问题
今天想在容器中安装一个pigz插件,于是就在dockerfile中使用RUN命令RUN apt-get install -y pigz结果构建镜像的时候报错Unable to locate packa ...
- 02hive数据类型
一. 基本数据类型 对于 Hive 的 String 类型相当于数据库的 varchar 类型,该类型是一个可变的字符串,不过它不能声明其中最多能存储多少个字符,理论上它可以存储 2GB 的字符数. ...