This post is all about the solution of the B. Gardener and the Array Codeforces Round #843 (Div. 2) Problem solution.
Problem Statement :
Kazimir Kazimirovich, the gardener, has an array of n integers c1,c2,...,cn.
He wants to see if there are two distinct subsequences of the original array, a and b, for which f(a)=f(b), where f(x) is the bitwise OR of all the numbers in the sequence x.
If q can be obtained from p by deleting several (possibly none or all) elements, q is a subsequence of p.
Two subsequences are considered distinct if their sets of indexes in the original sequence differ; that is, the values of the elements are ignored when comparing the subsequences.
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, Click Here
Also Check this out:-
A1. Gardener and the Capybaras (easy version) Codeforces Round #843 (Div. 2) Problem solution, Click Here
A2. Gardener and the Capybaras (hard version) Codeforces Round #843 (Div. 2) Problem solution, Click Here
B. Gardener and the Array Codeforces Round #843 (Div. 2) Problem solution, Click Here
C. Interesting Sequence Codeforces Round #843 (Div. 2) Problem solution, Click Here
D. Friendly Spiders Codeforces Round #843 (Div. 2) Problem solution, Click Here
Solution of the Problem: Click Here
0 Comments