CF1301A.Three Strings
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three strings a, b and c of the same length n. The strings consist of lowercase English letters only. The i-th letter of a is ai, the i-th letter of b is bi, the i-th letter of c is ci.
For every i (1≤i≤n) you must swap (i.e. exchange) ci with either ai or bi. So in total you'll perform exactly n swap operations, each of them either ci↔ai or ci↔bi (i iterates over all integers between 1 and n, inclusive).
For example, if a is "code", b is "true", and c is "help", you can make c equal to "crue" taking the 1-st and the 4-th letters from a and the others from b. In this way a becomes "hodp" and b becomes "tele".
Is it possible that after these swaps the string a becomes exactly the same as the string b?
给你三个长度均为 n 的字符串 a、b 和 c。这些字符串仅由小写英文字母组成。a 的第 i 个字母记为 ai,b 的第 i 个字母记为 bi,c 的第 i 个字母记为 ci。
对每个 i(1≤i≤n),你必须将 ci 与 ai 或 bi 中的一个交换(即互换位置)。因此,总共需执行恰好 n 次交换操作,每次操作要么是 ci↔ai,要么是 ci↔bi(其中 i 遍历所有从 1 到 n 的整数,含端点)。
例如,若 a 为 "code",b 为 "true",c 为 "help",你可以通过从 a 中取第 1 个和第 4 个字母、从 b 中取其余字母,使 c 变为 "crue"。这样,a 变为 "hodp",b 变为 "tele"。
在完成所有这些交换后,是否可能使字符串 a 恰好等于字符串 b?
输入格式
The input consists of multiple test cases. The first line contains a single integer t (1≤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 a.
The second line of each test case contains a string of lowercase English letters b.
The third line of each test case contains a string of lowercase English letters c.
It is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding 100.
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含一个由小写英文字母组成的字符串 a。
每个测试用例的第二行包含一个由小写英文字母组成的字符串 b。
每个测试用例的第三行包含一个由小写英文字母组成的字符串 c。
保证在每个测试用例中,这三个字符串均非空,且长度相同,长度不超过 100。
输出格式
Print t lines with answers for all test cases. For each test case:
If it is possible to make string a equal to string b print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print either lowercase or uppercase letters in the answers.
输出 t 行,对应所有测试用例的答案。对于每个测试用例:
- 如果可以将字符串 a 变为字符串 b,则输出 "YES"(不带引号);
- 否则输出 "NO"(不带引号)。
答案中的字母可以是小写或大写。
输入输出样例
输入#1
4 aaa bbb ccc abc bca bca aabb bbaa baba imi mii iim
输出#1
NO YES YES NO
说明/提示
In the first test case, it is impossible to do the swaps so that string a becomes exactly the same as string b.
In the second test case, you should swap ci with ai for all possible i. After the swaps a becomes "bca", b becomes "bca" and c becomes "abc". Here the strings a and b are equal.
In the third test case, you should swap c1 with a1, c2 with b2, c3 with b3 and c4 with a4. Then string a becomes "baba", string b becomes "baba" and string c becomes "abab". Here the strings a and b are equal.
In the fourth test case, it is impossible to do the swaps so that string a becomes exactly the same as string b.
在第一个测试用例中,无法通过交换使得字符串 a 恰好变为与字符串 b 相同。
在第二个测试用例中,应对所有可能的 i 交换 ci 与 ai。交换后,a 变为 "bca",b 变为 "bca",c 变为 "abc"。此时字符串 a 与 b 相等。
在第三个测试用例中,应交换 c1 与 a1、c2 与 b2、c3 与 b3、c4 与 a4。交换后,字符串 a 变为 "baba",字符串 b 变为 "baba",字符串 c 变为 "abab"。此时字符串 a 与 b 相等。
在第四个测试用例中,无法通过交换使得字符串 a 恰好变为与字符串 b 相同。
输入解题思路,AI测评打分。不知道怎么写?