This post is all about the solution of the C. Premutation Codeforces Round #847 (Div. 3) Problem solution.
Problem Statement :
Permutation refers to a sequence of n numbers that contains all integers from 1 to n exactly once. Permutations include the sequences [3,1,4,2], [1], and [2,1], but not [1,2,1], [0,1], and [1,3,4].
Kristina had a p-element permutation. She wrote it n times on the whiteboard in such a way that:
She skipped the element pi during the i-th (1in) time she wrote the permutation.
As a result, she wrote n sequences of length n1 each.
Assume Kristina has a permutation p = [4,2,1,3] of length 4. After that, she did the following:
I wrote the sequence [2,1,3], skipping the original permutation's element p1=4.
I wrote the sequence [4,1,3], skipping the original permutation's element p2=2.
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