E - Cellular Messenger Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 1000

問題文

すぬけ君は、あるマスに N ターンにわたり書き込まれる 01 列を離れたマスへ伝えるセル・オートマトンを設計したいと考えました。

1. グリッド

無限に広がるグリッドがあります。 各マスは 0 または 1 のいずれかの状態を持ちます。

グリッド上のある行を 0 行目、ある列を 0 列目とし、行番号は下向きに、列番号は右向きに 1 ずつ増えるように定めます。 r 行目、c 列目のマスの座標を (r,c) と表します。 各マスの座標は下図のようになります。

また、あるマスに隣接するマスとは、辺または頂点を共有する 8 マスを指します。

あなたは、以下の条件を満たす矩形領域を選び、領域内のマスの初期状態を自由に設定することができます。

  • 高さ H と幅 W がいずれも 1 以上 150 以下である
  • 左上のマスの座標が (0,0) である

領域外のマスの初期状態は全て 0 とします。

2. 更新操作

i=0,1j=0,1,\ldots,8 に対する 0 または 1 の値 F_{i,j} を決め、これらの値を更新規則とします。ただし、F_{0,0}=0 である必要があります。

更新操作では、全てのマスの状態を同時に更新します。 あるマスについて、更新前の状態を i、隣接する 8 マスの状態の総和を j とすると、更新後の状態は F_{i,j} となります。

3. オートマトンの設計

あなたは以下の値を決め、出力する必要があります。

  • 更新規則 F_{i,j} (i=0,1) (0 \le j \le 8)
    • F_{0,0}=0 でなければならない
  • 初期状態を設定する矩形領域の高さ H と幅 W
    • H, W はいずれも 1 以上 150 以下でなければならない
  • 矩形領域内の初期状態 A_{r,c} (0 \le r \lt H) (0 \le c \lt W)
  • 送信マスの座標 (R_s,C_s)受信マスの座標 (R_t,C_t)
    • 0 \le R_s,R_t \lt H かつ 0 \le C_s,C_t \lt W でなければならない
    • 50 \le |C_s-C_t| \le 100 でなければならない
  • 送信から受信までの遅延 D
    • k ターン目に送信マスに書き込んだ値を、k+D-1 ターン目に受信マスで読み取れるようにしなければならない
    • 50 \le D \le 100 でなければならない

4. ジャッジ方法

以下の手順でジャッジを行います。

  1. 正整数 N と、01 からなる長さ N の数列 S=(S_1,S_2, \ldots ,S_N) を決める。これらはテストケースごとに固定である。

  2. あなたが出力したオートマトンの設計を受け取る。

  3. 空の数列 T を用意し、初期状態から N+D-1 ターンのシミュレーションを行う。 具体的には、各 k=1,2,\ldots,N+D-1 について、k ターン目には以下の処理を順に行う。

    1. k \le N ならば、送信マス (R_s,C_s) の状態を S_k に変更する。
    2. グリッドに対して 1 回の更新操作を行う。
    3. D \le k < D+N ならば、受信マス (R_t,C_t) の状態を T の末尾に追加する。
  4. シミュレーションの終了後、S=T ならば正解、そうでなければ不正解となる。

N,S によらず正解となるオートマトンの設計が存在することは保証されますが、この問題ではジャッジの実装上、N および S はテストケースファイルごとに固定されており、N300 以下のケースでのみジャッジされます。

制約

  • ジャッジで使用される N1 以上 300 以下

入力

この問題では入力は与えられない。

出力

以下の形式で出力せよ。

F_{0,0}F_{0,1}\ldots F_{0,8}
F_{1,0}F_{1,1}\ldots F_{1,8}
H W
A_{0,0}A_{0,1}\ldots A_{0,W-1}
A_{1,0}A_{1,1}\ldots A_{1,W-1}
\vdots
A_{H-1,0}A_{H-1,1}\ldots A_{H-1,W-1}
R_s C_s R_t C_t D

出力は、以下の条件を満たす必要があります。

  • F_{i,j} \in \{0,1\}
  • F_{0,0} = 0
  • 1 \le H,W \le 150
  • A_{r,c} \in \{0,1\}
  • 0 \le R_s,R_t \lt H
  • 0 \le C_s,C_t \lt W
  • 50 \le |C_s-C_t| \le 100
  • 50 \le D \le 100

あなたの出力が条件を満たし、かつ用意された全てのテストケースについて上記のジャッジ方法で正解となった場合、この問題を正解したと見なされる。


出力例

000100000
001100000
4 54
100000000000000000000000000000000000000000000000000000
000010000000000000000000000000000000000000000000000000
100010000000000000000000000000000000000000000000000000
011110000000000000000000000000000000000000000000000000
0 3 0 53 100

この出力例は出力形式の確認のためのものです。 N=1 については全ての S について正解となりますが、2 \le N については不正解となる S が存在します。

ビジュアライザ

出力したオートマトンの動作は、ビジュアライザで確認することができます。

Score : 1000 points

Problem Statement

Snuke wants to design a cellular automaton that conveys a binary sequence, written into a certain cell over N turns, to a distant cell.

1. Grid

There is an infinitely large grid. Each cell has a state of 0 or 1.

Let some row of the grid be row 0 and some column be column 0, with row numbers increasing by 1 downward and column numbers increasing by 1 to the right. Let (r,c) denote the coordinates of the cell at row r and column c. The coordinates of the cells are as shown in the figure below.

The cells adjacent to a given cell refer to the eight cells sharing an edge or a vertex with it.

You may choose a rectangular region satisfying the following conditions, and freely set the initial states of the cells within the region.

  • Both the height H and the width W are between 1 and 150, inclusive.
  • The coordinates of the top-left cell are (0,0).

The initial states of all cells outside the region are 0.

2. Update Operation

Decide on a value F_{i,j}, either 0 or 1, for each i=0,1 and j=0,1,\ldots,8; let these values be the update rule. However, F_{0,0}=0 must hold.

In the update operation, the states of all cells are updated simultaneously. For a given cell, let i be its state before the update and j be the sum of the states of the eight adjacent cells; then its state after the update is F_{i,j}.

3. Designing the Automaton

You need to decide on and output the following values.

  • The update rule F_{i,j} (i=0,1) (0 \le j \le 8)
    • F_{0,0}=0 must hold.
  • The height H and width W of the rectangular region for which the initial state is set
    • Both H and W must be between 1 and 150, inclusive.
  • The initial states A_{r,c} (0 \le r \lt H) (0 \le c \lt W) within the rectangular region
  • The coordinates (R_s,C_s) of the sending cell and (R_t,C_t) of the receiving cell
    • 0 \le R_s,R_t \lt H and 0 \le C_s,C_t \lt W must hold.
    • 50 \le |C_s-C_t| \le 100 must hold.
  • The delay D from sending to receiving
    • It must be possible to read, at the receiving cell on turn k+D-1, the value that was written to the sending cell on turn k.
    • 50 \le D \le 100 must hold.

4. Judging Method

Judging is performed as follows.

  1. Decide on a positive integer N and a sequence S=(S_1,S_2, \ldots ,S_N) of length N consisting of 0s and 1s. These are fixed for each test case.

  2. Receive the design of the automaton that you output.

  3. Prepare an empty sequence T, and simulate N+D-1 turns starting from the initial state. Specifically, for each k=1,2,\ldots,N+D-1, perform the following steps in order on turn k.

    1. If k \le N, change the state of the sending cell (R_s,C_s) to S_k.
    2. Perform one update operation on the grid.
    3. If D \le k < D+N, append the state of the receiving cell (R_t,C_t) to the end of T.
  4. After the simulation ends, if S=T, your output is judged correct; otherwise, it is judged incorrect.

It is guaranteed that there exists a design of the automaton that is judged correct regardless of N and S, but due to implementation details of the judge for this problem, N and S are fixed for each test case file, and only cases with N \le 300 are used.

Constraints

  • The N used by the judge is between 1 and 300, inclusive.

Input

This problem provides no input.

Output

Output in the following format:

F_{0,0}F_{0,1}\ldots F_{0,8}
F_{1,0}F_{1,1}\ldots F_{1,8}
H W
A_{0,0}A_{0,1}\ldots A_{0,W-1}
A_{1,0}A_{1,1}\ldots A_{1,W-1}
\vdots
A_{H-1,0}A_{H-1,1}\ldots A_{H-1,W-1}
R_s C_s R_t C_t D

Your output must satisfy the following conditions.

  • F_{i,j} \in \{0,1\}
  • F_{0,0} = 0
  • 1 \le H,W \le 150
  • A_{r,c} \in \{0,1\}
  • 0 \le R_s,R_t \lt H
  • 0 \le C_s,C_t \lt W
  • 50 \le |C_s-C_t| \le 100
  • 50 \le D \le 100

If your output satisfies the above conditions, and is judged correct by the judging method described above for all prepared test cases, this problem is considered solved.


Sample Output

000100000
001100000
4 54
100000000000000000000000000000000000000000000000000000
000010000000000000000000000000000000000000000000000000
100010000000000000000000000000000000000000000000000000
011110000000000000000000000000000000000000000000000000
0 3 0 53 100

This sample output is provided to illustrate the output format. For N=1, it is correct for all S, but for 2 \le N, there exist some S for which it is incorrect.

Visualizer

You can check the behavior of your automaton using the visualizer.