#P10873. [COTS 2022] 帽子 Šeširi

    ID: 12344 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2022Special JudgeO2优化欧拉回路构造COCI(克罗地亚)Ad-hoc

[COTS 2022] 帽子 Šeširi

Background

Translated from Izborne Pripreme 2022 (Croatian IOI/CEOI Team Selection) D1T3. 3s,0.5G\texttt{3s,0.5G}.

I like Xiao Yuan!

Problem Description

NN OIers are wearing either red or white hats. Each person can only see the colors of the other people's hats, and they will guess the color of their own hat based on what they see.

They want to design a set of guessing strategies that satisfies the following conditions:

  • Suppose bb people wear white hats; then at least b2\lfloor\frac{b}{2}\rfloor of them guess their own hat color correctly.
  • Suppose cc people wear red hats; then at least c2\lfloor\frac{c}{2}\rfloor of them guess their own hat color correctly.

Help them find a strategy such that the conditions are satisfied in all 2N2^N possible cases.

Input Format

One line with one integer NN.

Output Format

Output NN lines. Each line is a string of length 2N12^{N-1} consisting of B,C\texttt{B},\texttt{C}.

The string on line ii describes the strategy of the ii-th OIer. Specifically:

  • Define f(S)f(S) as follows: sort all strings of length (N1)(N-1) consisting of B,C\texttt{B},\texttt{C} in lexicographical order, then f(S)f(S) is the rank of SS.
  • Let xx be the string output on line ii, and let si{B,C}s_i\in \{\texttt{B},\texttt{C}\} be the hat color worn by the ii-th OIer. Here, B\texttt{B} means white (Croatian: “bijela”), and C\texttt{C} means red (Croatian: “crvena”).
  • Let $y=\overline{s_1s_{2}\cdots s_{i-1}s_{i+1}\cdots s_n}$. Note that the left side is the most significant bit.
  • The color guessed by the ii-th OIer is xf(y)x_{f(y)}.

See [Sample Explanation].

2
BC
CC
3
BBCC
BCBC
BBCC

Hint

Sample Explanation

Take sample 22 as an example.

When s=CCCs=\texttt{CCC}, for the 11-st OIer, x=BBCCx=\texttt{BBCC} and y=CCy=\texttt{CC}. Clearly f(y)=4f(y)=4, so he will guess x4=Cx_4=\texttt{C}.

Scoring

Test point ID N=N= Score
11 44 77
22 55
33 66
44 77
55 88
66 99
77 1010
88 1111
99 1212
1010 1313
1111 1414 66
1212 1515
1313 1616
1414 1717
1515 1818

Translated by ChatGPT 5