CF1243B1.Character Swap (Easy Version)

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ss and tt of length nn 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 ii and jj (1≤i,j≤n1 \le i,j \le n, the values ii and jj can be equal or different), and swaps the characters sis_i and tjt_j. Can he succeed?

Note that he has to perform this operation exactly once. He has to perform this operation.

本题与困难版本不同。在本版本中,Ujan 恰好执行一次交换操作。仅当您同时解决了本题和困难版本时,才可对本题进行 Hack。

在多次尝试并失败后,Ujan 决定再次整理他的房子。他决定先将他的字符串理顺。

Ujan 有两个长度均为 nn 的互不相同的字符串 ss 和 tt,它们仅由小写英文字母组成。他希望使这两个字符串相等。由于 Ujan 很懒,他将恰好执行以下操作一次:选取两个位置 ii 和 jj(其中 1≤i,j≤n1 \le i,j \le n,ii 与 jj 可以相等,也可以不同),然后交换字符 sis_i 和 tjt_j。他能否成功?

注意:他必须且仅能执行该操作一次。

输入格式

The first line contains a single integer kk (1≤k≤101 \leq k \leq 10), the number of test cases.

For each of the test cases, the first line contains a single integer nn (2≤n≤1042 \leq n \leq 10^4), the length of the strings ss and tt.

Each of the next two lines contains the strings ss and tt, each having length exactly nn. The strings consist only of lowercase English letters. It is guaranteed that strings are different.

第一行包含一个整数 kk(1≤k≤101 \leq k \leq 10),表示测试用例的数量。

对于每个测试用例,第一行包含一个整数 nn(2≤n≤1042 \leq n \leq 10^4),表示字符串 ss 和 tt 的长度。

接下来的两行分别包含字符串 ss 和 tt,每个字符串的长度恰好为 nn。字符串仅由小写英文字母组成。保证两个字符串互不相同。

输出格式

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).

对于每个测试用例,如果 Ujan 能够使两个字符串相等,则输出 “Yes”,否则输出 “No”。

你可以以任意大小写(大写或小写)输出每个字母。

输入输出样例

  • 输入#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 s1s_1 and t4t_4, obtaining the word "house".

In the second test case, it is not possible to make the strings equal using exactly one swap of sis_i and tjt_j.

在第一个测试用例中,Ujan 可以交换字符 s1s_1 和 t4t_4,从而得到单词 “house”。

在第二个测试用例中,无法通过恰好一次交换 sis_i 和 tjt_j 使两个字符串相等。

输入解题思路,AI测评打分。不知道怎么写?

首页