CF1147E Rainbow Coins
Description
Carl has $ n $ coins of various colors, and he would like to sort them into piles. The coins are labeled $ 1,2,\ldots,n $ , and each coin is exactly one of red, green, or blue. He would like to sort the coins into three different piles so one pile contains all red coins, one pile contains all green coins, and one pile contains all blue coins.
Unfortunately, Carl is colorblind, so this task is impossible for him. Luckily, he has a friend who can take a pair of coins and tell Carl if they are the same color or not. Using his friend, Carl believes he can now sort the coins. The order of the piles doesn't matter, as long as all same colored coins are in the one pile, and no two different colored coins are in the same pile.
His friend will answer questions about multiple pairs of coins in batches, and will answer about all of those pairs in parallel. Each coin should be in at most one pair in each batch. The same coin can appear in different batches.
Carl can use only $ 7 $ batches. Help him find the piles of coins after sorting.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the example, there are three test cases.
In the first test case, there are three coins. We ask about the pairs $ (1,2) $ , $ (2,3) $ , and $ (1,3) $ in different batches and get that they are all the same color. Thus, we know all the coins are the same color, so we can put them all in one pile. Note that some piles can be empty and those are denoted with an empty line.
In the second test case, there are three coins again. This time, we only get that $ (1,3) $ are the same and $ (1,2) $ and $ (2,3) $ are different. So, one possible scenario is that coins $ 1 $ and $ 3 $ are red and coin $ 2 $ is green.
In the last case, there are $ 6 $ coins. The case shows how to ask and receive answers for multiple pairs in one batch.