This post is all about the solution of the D. Fixed Prefix Permutations Educational Codeforces Round 142 (Rated for Div. 2) Problem solution.
Problem Statement :
Eve is a newcomer to stand-up comedy. Her first performance drew only two people: Alice and Bob.
Eve had prepared a1+a2+a3+a4 jokes to tell, organised by type:
Type 1: Alice and Bob both like them; type 2: Alice likes them but Bob does not; type 3: Bob likes them but Alice does not; and type 4: neither Alice nor Bob likes them.
Initially, both observers' moods are equal to 0. When a spectator hears a joke he or she enjoys, his or her mood rises by 1. When a spectator hears a joke he or she dislikes, his or her mood drops by 1. If a spectator's mood becomes negative (lower than zero), he or she leaves.
Eve becomes depressed and ends the show when someone leaves.
Format of Input :
Each test contains a number of test cases. The first line contains the number t (1t500) of test cases. The test cases are described below.
A test case's only line contains the string s (3|s|100) — the capybaras' names written together. The string only contains the English letters 'a' and 'b'.
The sum of string lengths across all test cases is guaranteed not to exceed 500.
Format of the Output :
For every test case, print three strings a, b, and c separated by spaces on a single line — capybara names, such that writing them without spaces results in a line s. ab and cb, or ba and bc, must be satisfied.
If you have several options for restoring the names, print any of them. If the names are unable to be recovered, print ":(" (without quotes)
Also Check this out:-
A. GamingForces Educational Codeforces Round 142 (Rated for Div. 2) Problem solution, Click Here
B. Stand-up Comedian Educational Codeforces Round 142 (Rated for Div. 2) Problem solution, Click Here
C. Min Max Sort Educational Codeforces Round 142 (Rated for Div. 2) Problem solution, Click Here
D. Fixed Prefix Permutations Educational Codeforces Round 142 (Rated for Div. 2) Problem solution, Click Here
E. Divisors and Table Educational Codeforces Round 142 (Rated for Div. 2) Problem solution, Click Here
Solution of the Problem: Click Here
0 Comments