306722: CF1243B1. Character Swap (Easy Version)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Character Swap (Easy Version)

题意翻译

### 题意简述 给定两个长为 $n$ 的字符串 $s,t$。 您需要进行一次交换:找到一组 $i,j$ 满足 $1\leq i,j \leq n$,交换 $s_i$ 和 $t_j$。 问是否可以通过这次交换使得 $s=t$。 注意:您不能不进行交换。 ### 输入格式 第一行一个正整数 $k(1\leq k \leq 10)$,表示数据的组数。 对于每组数据,第一行一个正整数 $n(2\leq n \leq 10^4)$。 接下来一行一个字符串 $s$。 接下来一行一个字符串 $t$。 ### 输出格式 对于每组数据,如果可以通过一次交换使得 $s=t$,输出 `Yes`,否则输出 `No`。 您可以输出 `Yes` 和 `No` 的任意大小写形式。当答案为 `Yes` 时,输出 `yes`,`YES`,`YEs`,`yeS` 等答案都会被判为正确。 翻译贡献者 U108949

题目描述

This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems. After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first. Ujan has two distinct strings $ s $ and $ t $ of length $ n $ consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions $ i $ and $ j $ ( $ 1 \le i,j \le n $ , the values $ i $ and $ j $ can be equal or different), and swaps the characters $ s_i $ and $ t_j $ . Can he succeed? Note that he has to perform this operation exactly once. He has to perform this operation.

输入输出格式

输入格式


The first line contains a single integer $ k $ ( $ 1 \leq k \leq 10 $ ), the number of test cases. For each of the test cases, the first line contains a single integer $ n $ ( $ 2 \leq n \leq 10^4 $ ), the length of the strings $ s $ and $ t $ . Each of the next two lines contains the strings $ s $ and $ t $ , each having length exactly $ n $ . The strings consist only of lowercase English letters. It is guaranteed that strings are different.

输出格式


For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise. You can print each letter in any case (upper or lower).

输入输出样例

输入样例 #1

4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca

输出样例 #1

Yes
No
No
No

说明

In the first test case, Ujan can swap characters $ s_1 $ and $ t_4 $ , obtaining the word "house". In the second test case, it is not possible to make the strings equal using exactly one swap of $ s_i $ and $ t_j $ .

Input

题意翻译

### 题意简述 给定两个长为 $n$ 的字符串 $s,t$。 您需要进行一次交换:找到一组 $i,j$ 满足 $1\leq i,j \leq n$,交换 $s_i$ 和 $t_j$。 问是否可以通过这次交换使得 $s=t$。 注意:您不能不进行交换。 ### 输入格式 第一行一个正整数 $k(1\leq k \leq 10)$,表示数据的组数。 对于每组数据,第一行一个正整数 $n(2\leq n \leq 10^4)$。 接下来一行一个字符串 $s$。 接下来一行一个字符串 $t$。 ### 输出格式 对于每组数据,如果可以通过一次交换使得 $s=t$,输出 `Yes`,否则输出 `No`。 您可以输出 `Yes` 和 `No` 的任意大小写形式。当答案为 `Yes` 时,输出 `yes`,`YES`,`YEs`,`yeS` 等答案都会被判为正确。 翻译贡献者 U108949

加入题单

算法标签: