Kotlin Heroes: Practice 7

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1532 Kotlin Heroes: Practice 7 FINISHED False 604800 152123084 June 22, 2021, 1:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 219 ) F Prefixes and Suffixes PROGRAMMING *special strings

Ivan wants to play a game with you. He picked some string (s) of length (n) consisting only of lowercase Latin letters. You don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of lengths from (1) to (n-1)), but he didn't tell you which strings are prefixes and which are suffixes. Ivan wants you to guess which of the given (2n-2) strings are prefixes of the given string and which are suffixes. It may be impossible to guess the string Ivan picked (since multiple strings may give the same set of suffixes and prefixes), but Ivan will accept your answer if there is at least one string that is consistent with it. Let the game begin! The first line of the input contains one integer number (n) ((2 \le n \le 100)) — the length of the guessed string (s). The next (2n-2) lines are contain prefixes and suffixes, one per line. Each of them is the string of length from (1) to (n-1) consisting only of lowercase Latin letters. They can be given in arbitrary order. It is guaranteed that there are exactly (2) strings of each length from (1) to (n-1). It is also guaranteed that these strings are prefixes and suffixes of some existing string of length (n). Print one string of length (2n-2) — the string consisting only of characters ' P ' and ' S '. The number of characters ' P ' should be equal to the number of characters ' S '. The (i)-th character of this string should be ' P ' if the (i)-th of the input strings is the prefix and ' S ' otherwise. If there are several possible answers, you can print any . The only string which Ivan can guess in the first example is " ababa ". The only string which Ivan can guess in the second example is " aaa ". Answers " SPSP ", " SSPP " and " PSPS " are also acceptable. In the third example Ivan can guess the string " ac " or the string " ca ". The answer " SP " is also acceptable.

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
120823357 Andreasyan F June 28, 2021, 5:23 p.m. OK Kotlin TESTS 54 109 0
120766170 Etherite F June 28, 2021, 12:08 a.m. OK Kotlin TESTS 54 109 0
120364571 marksman_ F June 23, 2021, 12:04 p.m. OK Kotlin TESTS 54 109 0
120341730 shivangtiwari F June 23, 2021, 6:21 a.m. OK Kotlin TESTS 54 109 0
120319021 danegor F June 22, 2021, 6:37 p.m. OK Kotlin TESTS 54 109 0
120867084 galen_colin F June 29, 2021, 10:51 a.m. OK Kotlin TESTS 54 124 0
120845909 Kasarapu_Charan F June 29, 2021, 5:06 a.m. OK Kotlin TESTS 54 124 0
120838821 Geothermal F June 29, 2021, 1:20 a.m. OK Kotlin TESTS 54 124 0
120832195 Bench0310 F June 28, 2021, 8:03 p.m. OK Kotlin TESTS 54 124 0
120708409 jianzhi F June 27, 2021, 5:26 a.m. OK Kotlin TESTS 54 124 0

remove filters

Back to search problems