标签: 并查集

「CodeForces 1250E」 The Coronation

The coronation of King Berl XXII is soon! The whole royal family, including 𝑛 daughters of Berl XXII, will be present.

The King has ordered his jeweler to assemble 𝑛 beautiful necklaces, so each of the princesses could wear exactly one necklace during the ceremony — and now these necklaces are finished. Each necklace consists of 𝑚 gems attached to a gold chain. There are two types of gems used in the necklaces — emeralds and sapphires. So, each necklace can be represented by a sequence of 𝑚 gems (listed from left to right), and each gem is either an emerald or a sapphire. Formally, the 𝑖-th necklace can be represented by a binary string 𝑠𝑖 of length 𝑚; if the 𝑗-th character of 𝑠𝑖 is 0, then the 𝑗-th gem in the 𝑖-th necklace is an emerald; otherwise, this gem is a sapphire.

「POJ 1417」True Liars

After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember a legend of the foggy island, which he had heard from patriarchs in his childhood. This must be the island in the legend. In the legend, two tribes have inhabited the island, one is divine and the other is devilish, once members of the divine tribe bless you, your future is bright and promising, and your soul will eventually go to Heaven, in contrast, once members of the devilish tribe curse you, your future is bleak and hopeless, and your soul will eventually fall down to Hell.