This post is all about the solution of the B. Taisia and Dice Codeforces Round #847 (Div. 3) Problem solution.
Problem Statement :
Taisia possesses a six-sided die. Each die face is labelled with a number from 1 to 6, and each number is only used once.
Taisia rolls all n dice simultaneously and receives a sequence of values a1,a2,...,an (1ai6), where ai is the value on the upper face of the i-th dice. This sequence's sum is equal to s.
Suddenly, Taisia's pet cat steals the maximum value ai dice and computes the sum of the values on the remaining n1 dice, which equals r.
You only know how many dice there are, n, and what the values of s and r are. Bring back a possible sequence a that meets the constraints.
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