This post is all about the solution of the D. Matryoshkas Codeforces Round #847 (Div. 3) Problem solution.
Problem Statement :
Matryoshka is a wooden toy in the shape of a painted doll, inside which you can place a smaller doll.
A nesting doll set consists of one or more nesting dolls whose sizes are consecutive positive integers. As a result, a nesting doll set is described by two numbers: s — the size of the smallest nesting doll in the set — and m — the number of dolls in the set. In other words, for some integer s and m (s,m>0), the set has sizes of s,s+1,...,s+m1.
You had one or more nesting doll sets. You recently discovered that someone had combined all of your sets into one and recorded a sequence of doll sizes — integers a1,a2,...,an.
You have no idea how many sets you have.
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. Polycarp and the Day of Pi Codeforces Round #847 (Div. 3) Problem solution, Click Here
B. Taisia and Dice Codeforces Round #847 (Div. 3) Problem solution, Click Here
C. Premutation Codeforces Round #847 (Div. 3) Problem solution, Click Here
D. Matryoshkas Codeforces Round #847 (Div. 3) Problem solution, Click Here
E. Vlad and a Pair of Numbers Codeforces Round #847 (Div. 3) Problem solution, Click Here
F. Timofey and Black-White Tree Codeforces Round #847 (Div. 3) Problem solution, Click Here
Solution of the Problem: Click Here
0 Comments