CF186A.Comparing Strings

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.

Dwarf Misha has already chosen the subject for his thesis: determining by two dwarven genomes, whether they belong to the same race. Two dwarves belong to the same race if we can swap two characters in the first dwarf's genome and get the second dwarf's genome as a result. Help Dwarf Misha and find out whether two gnomes belong to the same race or not.

一些即将完成“矮人青年州立大学”(StUDY,State University for Dwarven Youngsters)本科课程的矮人被告知:“无基因组,无学位”。这意味着所有矮人都必须撰写一篇关于基因组的毕业论文。矮人的基因组远非简单:它由一串小写拉丁字母组成的字符串表示。

矮人米沙(Misha)已为其毕业论文选定了课题:给定两个矮人基因组,判断它们是否属于同一族群。若能通过对第一个矮人基因组中恰好两个字符进行一次交换,从而得到第二个矮人基因组,则这两个矮人属于同一族群。请帮助矮人米沙判断:给定的两个基因组是否属于同一族群。

输入格式

The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that correspond to the genomes are different. The given genomes may have different length.

第一行包含第一个矮人的基因组:一个非空字符串,由小写拉丁字母组成。

第二行包含第二个矮人的基因组:一个非空字符串,由小写拉丁字母组成。

每个基因组中的字母数量不超过 10510^5。保证对应于基因组的字符串互不相同。给定的基因组长度可能不同。

输出格式

Print "YES", if the dwarves belong to the same race. Otherwise, print "NO".

如果这些矮人属于同一种族,则输出 “YES”;否则,输出 “NO”。

输入输出样例

  • 输入#1

    ab
    ba

    输出#1

    YES
  • 输入#2

    aa
    ab

    输出#2

    NO

说明/提示

  • First example: you can simply swap two letters in string "ab". So we get "ba".

  • Second example: we can't change string "aa" into string "ab", because "aa" does not contain letter "b".

  • 第一个例子:您可以简单地交换字符串 “ab” 中的两个字母,从而得到 “ba”。

  • 第二个例子:无法将字符串 “aa” 变为字符串 “ab”,因为 “aa” 中不包含字母 “b”。

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

首页