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相同. 思路:对于每一个位置,如果三个字符 ...
随机推荐
- HDU多校第三场 Hdu6606 Distribution of books 线段树优化DP
Hdu6606 Distribution of books 题意 把一段连续的数字分成k段,不能有空段且段和段之间不能有间隔,但是可以舍去一部分后缀数字,求\(min(max((\sum ai ))\ ...
- D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...
- 每天进步一点点------Allegro 布线完成后如何修改线宽
一.如果要改变整个一条导线的宽度 1.在find栏里选择Cline; 2.在PCB中选择要改的导线,点击右键,选择Change Width 3.在对话框中输入你想要的线宽 3.如果要改变整个导线 ...
- linux deploy---旧手机变废为宝
前几天朋友送了我一部红米Note 1s,本来不想要,转念一想,不要白不要,就收了. 拿到之后我就想,这么一个1+8的手机能做什么呢? 翻遍了CSDN和简书,找到了一个性价比不错的方法:给旧手机装上一个 ...
- codeforces 1189C Candies! / 前缀和
http://codeforces.com/problemset/problem/1189/C 求一下前缀和,给定区间的数字和除以10就是答案 AC代码: #include<iostream&g ...
- vue中移动端调取本地的复制的文本
_this.$vux.confirm.show({ title: '复制分享链接', content: ‘分享的内容’, onConfi ...
- 吴裕雄 python 机器学习——集成学习梯度提升决策树GradientBoostingRegressor回归模型
import numpy as np import matplotlib.pyplot as plt from sklearn import datasets,ensemble from sklear ...
- go key-value缓存go-cache实现
Cache类型 Cache封装了一个cache类型,cache类型的参数解析: 1.defaultExpiration time.Duration 每个键值的默认过期时间. 2.items map[s ...
- 【游戏体验】Shoot'm(暴打火柴人)
>>>点此处可试玩无敌版<<< 注意,本游戏含有少量暴力元素,13岁以下的儿童切勿尝试本款游戏 生活有压力,学习不如意,你可以尝试这款游戏发泄心中的不满 个人测评 ...
- vim配置之——ctags与TagList的配置以及NERDTree && doxygentoolkit的安装
参考(2)vim插件:显示树形目录插件NERDTree安装 和 使用 本文档主要对Linux下vim的ctags,TagList,NerdTree与doxgentoolkit进行相关的配置. 以下部分 ...