CrazyCrazy
TCO19 SRM 756 · 2019-04-24 · by IH19980412
Problem Statement
Shiki and Frederica are friends who like listening to songs together. They use a single cell phone to play the song, and each of them listens to it using one earphone.
For the purpose of this problem, a song is a string of lowercase English letters. Each letter represents one note of the song. The length of the song is always even.
Today the girls' music app became broken and something weird happened: each note of the song was only sent to one of the earphones.
Once the song was over, an even weirder thing happened: Shiki repeated the song she heard and Frederica realized that she has heard the exact same sequence of notes.
You are given a
If song can be the girls' favorite song, return "possible". Otherwise, return "impossible".
Constraints
- N will be between 2 and 40, inclusive.
- N will be even.
- Length of song will be exactly N.
- song will consist of lowercase English letters only ('a'-'z')
"aabb" Returns: "possible"
One possibility is that the characters are sent as follows: 'a' to Shiki 'a' to Frederica 'b' to Shiki 'b' to Frederica This way, each of the girls will hear the string "ab".
"abba" Returns: "impossible"
"verylazyverylazy" Returns: "possible"
One possible scenario: Shiki hears the first eight characters and Frederica hears the rest.
"arqmpfvvbtltlhufznkldkurrazmgebfxeamrewn" Returns: "impossible"
"aacfcfqqsmksimkoioeertbrtbhphnpnggddjjll" Returns: "possible"
Submissions are judged against all 75 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CrazyCrazy with a public method string possible(string song) · 75 test cases · 2 s / 256 MB per case