Given a string, decide whether some character can be swapped for a different character that normalizes to the same form.
Easy3StringHash mapImplementationString matchingNo attempts yetTime limit1sMemory limit256 MBThere are a great many kinds of characters in the world. Unicode was created so that every digital device handles them the same way, and it is still being updated. Along the way, some characters came out looking similar to each other, and some came out with exactly the same shape. The IDN homograph attack abuses that.
Han characters have an unusually large number of look-alikes, because several countries use them and each country writes them a little differently. Take 糖水肉, the Han spelling of the dish tangsuyuk. The first character 糖(U+FA03) has the same shape as 糖(U+7CD6), the second character 水(U+6C34) has the same shape as ⽔(U+2F54), and the third character 肉(U+8089) has the same shape as ⾁(U+2F81). Replacing any one of them changes the string while the text on screen stays the same, so a user cannot tell the two strings apart.
In this problem the Unicode character database decides whether two characters have the same shape. A character is a duplicate when it belongs to one of the three blocks below and its decomposition is a single character other than itself. That single character is the representative of the duplicate.
A character that is not a duplicate is its own representative. Two characters have the same shape when they share a representative. If your environment provides NFKC normalization, the representative of a character in those three blocks is its NFKC form.
Given a string, write a program that decides whether replacing one or more of its characters with a different character of the same shape can produce a string different from the original.
The input is one line. Every character of the string is defined in the Unicode Basic Multilingual Plane (BMP), and the string is at most 1,000 characters long.
Print Yes if replacing one or more characters of the string with a different character of the same shape produces a string different from the original. Otherwise print No.