Multi Communication

시간 제한1초메모리 제한2048 MB

요약
한 명만 T인 비밀 표식을 두고 N명의 참가자가 L턴 안에 부모를 알아내도록 전략을 설계하고 모든 행동을 출력한다.
난이도

어려움10점 중 9점

유형
조합론, 시뮬레이션, 수학, 비트 연산
정답자
아직 제출이 없습니다

문제

Chairman K has prepared a game for the participants of the spring training camp.

There are NN participants in the training camp, each assigned a unique number from 11 to NN. Each participant has a board. The game follows these steps:

  1. Chairman K selects one participant to be the parent, while all other participants become children. However, the identity of the parent is not revealed to the participants.

  2. Chairman K writes the letter ‘T’ on the parent’s board and the letter ‘F’ on all the children’s boards.

  3. Each participant reads the letter on their own board. Then, following a predefined strategy, they perform the following turn-based process for LL turns:

    1. Each participant erases the letter on their board and writes either ‘T’ or ‘F’. Then, they submit their board to Chairman K.
    2. For each participant ii (i=1,2,…,Ni = 1, 2, \dots , N):
      • Participant ii selects a participant pp (1≤p≤N1 ≤ p ≤ N) and informs Chairman K of the number pp. Chairman K shows the board of participant pp to participant ii, who then reads the letter on it. A participant is allowed to choose themselves as pp.
  4. After LL turns, each participant must guess who the parent is.

The goal of the game is to establish a strategy beforehand so that, regardless of who is chosen as the parent, all participants can correctly identify the parent by the end of the process.

A smaller value of LL results in a higher score. Your goal is to devise a strategy that minimizes LL while ensuring that all participants correctly identify the parent by the end of the process.

A strategy consists of a non-negative integer LL, representing the number of turns, and a set of rules that determine the actions of each participant. The rules are as follows:

  • For participant ii (1≤i≤N1 ≤ i ≤ N), at the beginning of turn tt (1≤t≤L1 ≤ t ≤ L), if the sequence of letters they have read up to that point is a_0,a_1,…,a_t−1a\_0, a\_1, \dots , a\_{t-1}, then based only on this information (i,t,a_0,a_1,…,a_t−1)(i, t, a\_0, a\_1, \dots , a\_{t-1}), they must determine:

    • The letter they will write on their board for turn tt.
    • The participant number they will choose to observe for turn tt.
  • For participant ii (1≤i≤N1 ≤ i ≤ N), after the LL-th turn, if the sequence of letters they have read up to that point is a_0,a_1,…,a_La\_0, a\_1, \dots , a\_L, then based only on this information (i,L,a_0,a_1,…,a_L)(i, L, a\_0, a\_1, \dots , a\_L), they must determine the participant number of the parent.

Devise a strategy that allows all participants to correctly identify the parent, regardless of who is chosen as the parent. Then, for each possible parent selection (1,2,…,N)(1, 2, \dots , N), output the values that each participant writes on their board and the participant they choose to observe in each turn, following the established strategy.

입력

Read the following data from the standard input.

NN

출력

Print the output in the following format:

LL

acts_1acts\_1

acts_2acts\_2

⋮\vdots

acts_Nacts\_N

Here, acts_sacts\_s represents the sequence of actions taken by each participant when participant ss is the parent. The format of acts_sacts\_s is as follows:

First, print the integer ss. For each participant ii (1≤i≤N1 ≤ i ≤ N), print a single line containing the sequence of actions they take during the LL turns. Each line should have the following values:

  • The character c_i,tc\_{i,t} (‘T’ or ‘F’), which the participant writes on their board in turn tt.
  • The participant number p_i,tp\_{i,t}, which they choose to observe in turn tt.

These values should be printed for each turn tt (1≤t≤L1 ≤ t ≤ L) in sequence. Thus, the output format for acts_sacts\_s is:

ss

c_1,1c\_{1,1} p_1,1p\_{1,1} c_1,2c\_{1,2} p_1,2p\_{1,2} ⋯\cdots c_1,Lc\_{1,L} p_1,Lp\_{1,L}

c_2,1c\_{2,1} p_2,1p\_{2,1} c_2,2c\_{2,2} p_2,2p\_{2,2} ⋯\cdots c_2,Lc\_{2,L} p_2,Lp\_{2,L}

⋮\vdots

c_N,1c\_{N,1} p_N,1p\_{N,1} c_N,2c\_{N,2} p_N,2p\_{N,2} ⋯\cdots c_N,Lc\_{N,L} p_N,Lp\_{N,L}

제한

  • NN is one of 44, 3232, or 4848.

예제1

  1. 예제 1

    입력
    3
    
    예상 출력
    3
    1
    T 1 T 2 T 3
    F 1 F 2 F 3
    F 1 F 2 F 3
    2
    F 1 F 2 F 3
    T 1 T 2 T 3
    F 1 F 2 F 3
    3
    F 1 F 2 F 3
    F 1 F 2 F 3
    T 1 T 2 T 3