This post is all about the solution of the D. Score of a Tree Codeforces Round #845 (Div. 2) and ByteRace 2023 Problem solution.

D. Score of a Tree Codeforces Round #845 (Div. 2) and ByteRace 2023 Problem solution

Codeforces



Problem Statement :

Petya and his friend, robot Petya++, enjoy solving challenging math problems.

Petya++ came up with the numbers n and x one day and wrote the equation on the board: n & (n+1) &... & m=x, where & denotes the bitwise AND operation. Then he suggested to his friend Petya to find such a small m (mn) that the equality on the board is preserved.

Unfortunately, Petya was unable to solve the problem in his head and decided to seek computer assistance. He quickly wrote a programme and discovered the solution.

Can you solve this challenging problem?


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)


New Upcoming OnePlus 11 Specifications

New Upcoming OnePlus 11 Specifications, Click Here

Also Check this out:-

B. Emordnilap Codeforces Round #845 (Div. 2) and ByteRace 2023 Problem Solution, Click Here
C. Quiz Master Codeforces Round #845 (Div. 2) and ByteRace 2023 Problem solution, Click Here
D. Score of a Tree Codeforces Round #845 (Div. 2) and ByteRace 2023 Problem solution, Click Here
Solution of the Problem: Click Here