Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
1,2, \dots ,N の番号がついた N 個の会議があります。 会議 i の開始時刻は S_i、終了時刻は T_i です。
高橋君と青木君は、各会議に 2 人のうちちょうど一方を担当者として割り当てようとしています。 正の長さの時間帯で重なる 2 個の会議を同じ人が担当することはできません。 より厳密には、会議 i と会議 j を同じ人が担当することができるのは、T_i \le S_j または T_j \le S_i を満たすときに限ります。
条件を満たす担当者の割り当て方の個数を 998244353 で割った余りを求めてください。
制約
- 1 \le N \le 3 \times 10^5
- 1 \le S_i < T_i \le 2N
- S_1,T_1,S_2,T_2,\dots,S_N,T_N は全て異なる
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N S_1 T_1 S_2 T_2 \vdots S_N T_N
出力
条件を満たす担当者の割り当て方の個数を 998244353 で割った余りを出力せよ。
入力例 1
3 1 3 2 4 5 6
出力例 1
4
条件を満たす割り当て方は、以下の 4 通りです。
- 高橋君が会議 1,3、青木君が会議 2 を担当する。
- 高橋君が会議 1、青木君が会議 2,3 を担当する。
- 高橋君が会議 2,3、青木君が会議 1 を担当する。
- 高橋君が会議 2、青木君が会議 1,3 を担当する。
入力例 2
3 1 4 2 5 3 6
出力例 2
0
条件を満たす割り当て方は 0 通りです。
Score : 400 points
Problem Statement
There are N meetings numbered 1,2,\dots,N. Meeting i starts at time S_i and ends at time T_i.
Takahashi and Aoki are going to assign exactly one of themselves to each meeting as the person in charge. The same person cannot be in charge of two meetings that overlap for a positive length of time. More formally, the same person can be in charge of meetings i and j only if T_i \le S_j or T_j \le S_i.
Find the number, modulo 998244353, of ways to assign the people in charge that satisfy the conditions.
Constraints
- 1 \le N \le 3 \times 10^5
- 1 \le S_i < T_i \le 2N
- S_1,T_1,S_2,T_2,\dots,S_N,T_N are all different.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N S_1 T_1 S_2 T_2 \vdots S_N T_N
Output
Output the number, modulo 998244353, of ways to assign the people in charge that satisfy the conditions.
Sample Input 1
3 1 3 2 4 5 6
Sample Output 1
4
The following four assignments satisfy the conditions:
- Takahashi is in charge of meetings 1,3, and Aoki is in charge of meeting 2.
- Takahashi is in charge of meeting 1, and Aoki is in charge of meetings 2,3.
- Takahashi is in charge of meetings 2,3, and Aoki is in charge of meeting 1.
- Takahashi is in charge of meeting 2, and Aoki is in charge of meetings 1,3.
Sample Input 2
3 1 4 2 5 3 6
Sample Output 2
0
Zero assignments satisfy the conditions.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
1,2,\dots,N の番号がついた N 個の袋があります。 また、各 i=0,1,\dots,M-1 について、重さ 2^i の荷物が A_i 個あります。 荷物は合計 A_0+A_1+\dots+A_{M-1} 個です。
全ての荷物を、それぞれいずれか 1 個の袋に入れます。空の袋があっても構いません。
各袋について、その袋に入っている全ての荷物の重さの総和を袋の重量と呼びます。
N 個の袋の重量の最大値としてあり得る最小の値を求めてください。
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- 1 \le T \le 10^5
- 1 \le N \le 10^6
- 1 \le M \le 40
- 0 \le A_i \le 10^6
- 全てのテストケースにおける M の総和は 2 \times 10^5 以下
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
各テストケースは以下の形式で与えられる。
N M
A_0 A_1 \ldots A_{M-1}
出力
T 行出力せよ。
i 行目には i 番目のテストケースについて、袋の重量の最大値としてあり得る最小の値を出力せよ。
入力例 1
4 2 3 3 2 1 1000000 1 0 1 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 188075 10 858153 791486 630853 157728 813993 50047 286602 459270 597406 907405
出力例 1
6 0 549755813888 3805
1 個目のテストケースでは、重さ 1,2,4 の荷物がそれぞれ 3,2,1 個あります。
例えば、袋 1,2 に入れる荷物の重さをそれぞれ (4,1,1),(2,2,1) とします。 このとき、袋 1,2 の重量はそれぞれ 6,5 であり、その最大値は 6 です。
袋の重量の最大値を 5 以下にすることはできません。
Score : 500 points
Problem Statement
There are N bags numbered 1,2,\dots,N. Also, for each i=0,1,\dots,M-1, there are A_i packages of weight 2^i. There are A_0+A_1+\dots+A_{M-1} packages in total.
Every package is put into exactly one of the bags. Some bags may remain empty.
For each bag, the sum of the weights of all packages in that bag is called the weight of the bag.
Find the minimum possible value of the maximum of the weights of the N bags.
You are given T test cases; solve each of them.
Constraints
- 1 \le T \le 10^5
- 1 \le N \le 10^6
- 1 \le M \le 40
- 0 \le A_i \le 10^6
- The sum of M over all test cases is at most 2 \times 10^5.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N M
A_0 A_1 \ldots A_{M-1}
Output
Output T lines.
The i-th line should contain the minimum possible value of the maximum of the weights of the bags for the i-th test case.
Sample Input 1
4 2 3 3 2 1 1000000 1 0 1 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 188075 10 858153 791486 630853 157728 813993 50047 286602 459270 597406 907405
Sample Output 1
6 0 549755813888 3805
In the first test case, there are 3,2,1 packages of weight 1,2,4, respectively.
For example, let the weights of the packages put into bags 1,2 be (4,1,1),(2,2,1), respectively. Then, the weights of bags 1,2 are 6,5, respectively, and the maximum of these is 6.
It is impossible to make the maximum of the weights of the bags 5 or less.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 700 点
問題文
H 行 W 列のマス目があります。 上から i 行目、左から j 列目のマスを (i,j) と表します。 はじめ、全てのマスは白です。
以下の操作を好きな回数行います。
-
以下の条件を全て満たす整数 r,c,s を選び、マス (r,c),(r+s,c),(r,c+s),(r+s,c+s) を黒く塗る。
- 1\le r<r+s\le H
- 1\le c<c+s\le W
- マス (r,c),(r+s,c),(r,c+s),(r+s,c+s) が全て白。
行うことができる操作回数の最大値を求め、その最大値を達成する操作列を 1 つ出力してください。
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- 1\le T\le 500
- 2\le H,W\le 500
- 全てのテストケースにおける HW の総和は 250000 以下
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
各テストケースは以下の形式で与えられる。
H W
出力
各テストケースについて、操作回数の最大値を K、i 回目の操作で選ぶ整数を r_i,c_i,s_i とし、以下の形式で出力せよ。
K r_1 c_1 s_1 r_2 c_2 s_2 \vdots r_K c_K s_K
最大値を達成する操作列が複数存在する場合、どれを出力しても正解となる。
入力例 1
2 5 6 2 2
出力例 1
6 1 1 3 3 4 2 1 2 3 3 3 2 1 3 3 2 1 1 1 1 1 1
1 個目のテストケースについて、出力された 6 回の操作を行うと、黒く塗られるマスは以下のようになります。
数字 i は i 回目の操作で黒く塗られるマスを表し、. は最後まで塗られないマスを表します。
135135 66.... 664242 135135 ..4242
この出力以外にも正解となる出力は存在します。
Score : 700 points
Problem Statement
There is a grid with H rows and W columns. Let (i,j) denote the cell at the i-th row from the top and the j-th column from the left. Initially, all cells are white.
You may perform the following operation any number of times.
-
Choose integers r,c,s satisfying all of the following conditions, and paint the cells (r,c),(r+s,c),(r,c+s),(r+s,c+s) black.
- 1\le r<r+s\le H
- 1\le c<c+s\le W
- The cells (r,c),(r+s,c),(r,c+s),(r+s,c+s) are all white.
Find the maximum number of operations you can perform, and output one sequence of operations that achieves that maximum.
You are given T test cases; solve each of them.
Constraints
- 1\le T\le 500
- 2\le H,W\le 500
- The sum of HW over all test cases is at most 250000.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
H W
Output
For each test case, let K be the maximum possible number of operations, and let r_i,c_i,s_i be the integers chosen in the i-th operation; output them in the following format:
K r_1 c_1 s_1 r_2 c_2 s_2 \vdots r_K c_K s_K
If there are multiple sequences of operations that achieve the maximum, any of them will be accepted.
Sample Input 1
2 5 6 2 2
Sample Output 1
6 1 1 3 3 4 2 1 2 3 3 3 2 1 3 3 2 1 1 1 1 1 1
For the first test case, performing the six output operations paints the following cells black.
The digit i represents a cell painted black by the i-th operation, and . represents a cell that is never painted.
135135 66.... 664242 135135 ..4242
There are other outputs that will be accepted.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 800 点
問題文
この問題はインタラクティブな問題(あなたの作成したプログラムとジャッジが入出力を介して対話を行う形式の問題)です。
1 から 5 までの番号がついた 5 本のキューがあります。 はじめ、全てのキューは空です。
ジャッジから、以下の 2 種類のクエリがそれぞれ Q 回、合計 2Q 回与えられます。
- push クエリ:ジャッジから整数 X が与えられ、キュー 1 の末尾に追加される。各 push クエリで与えられる整数 X は全て相異なる。あなたはその後、以下の移動操作を 0 回以上行うことができる。
- 移動操作:1 \le i,j \le 5 を満たす整数 i,j を選び、キュー i の先頭の値を取り除いてキュー j の末尾に追加する。ただし、空のキューを i として選ぶことはできない。i\ne j である必要はない。
- pop クエリ:ジャッジは、1 本以上のキューが空でない状態でのみこのクエリを与える。あなたは 1 \le i \le 5 を満たす整数 i を選ぶ。このとき、キュー i は空でなく、その先頭の値が、その時点で 5 本のキューに入っている全ての値のうち最小でなければならない。その後、ジャッジがキュー i の先頭の値を取り除く。
移動操作は合計で 10^5 回までしか行えません。 全てのクエリに正しく応答するプログラムを作成してください。
制約
- 1 \le Q \le 5000
- 1 \le X \le 10^9
- 各 push クエリで追加される値 X は全て相異なる
- push クエリと pop クエリはそれぞれ Q 回ずつ与えられる
- 各 pop クエリが与えられる時点で、1 本以上のキューが空でない
- 入力される値は全て整数
入出力
この問題はインタラクティブな問題です。
まず、ジャッジから正整数 Q が以下の形式で与えられます。
Q
その後、以下のやり取りを 2Q 回行ってください。 各回では、まずジャッジから push クエリまたは pop クエリが与えられます。
push クエリは以下の形式で与えられます。
1 X
pop クエリは以下の形式で与えられます。
2
(なお、直前のクエリへの応答が不正であった場合、クエリの代わりに -1 が標準入力から与えられます。この場合はただちにプログラムを正常終了してください。ただし、2Q 個目のクエリへの応答で初めて不正な出力を行った場合、その後の入力は何も与えられません。)
push クエリが与えられた場合、行う移動操作の回数を k とし、r 回目の移動操作で選ぶキューの番号を i_r,j_r として、以下の形式で k+1 行出力してください。出力後、必ず改行してください。
k i_1 j_1 i_2 j_2 \vdots i_k j_k
pop クエリが与えられた場合、先頭の値を取り除くキューの番号 i を以下の形式で出力してください。出力後、必ず改行してください。
i
注意点
- 各クエリへの応答を出力するたびに、末尾に改行を入れて標準出力を flush してください。そうしなかった場合、ジャッジ結果が TLE となる可能性があります。
- ジャッジから
-1という入力を受け取った場合は、ただちにプログラムを正常終了してください。終了した場合のジャッジ結果は WA となりますが、終了しなかった場合のジャッジ結果は不定です。 - 余分な改行は不正な形式の出力とみなされるため、行わないでください。
- 2Q 個のクエリへの応答を終えたら、ただちにプログラムを終了してください。そうしない場合、ジャッジ結果は不定です。
- この問題のジャッジは適応的(adaptive)ではありません。ジャッジは、対話前にクエリの種類と順序、および各 push クエリで与える整数 X を決定しています。
入出力例
以下は Q=2 で、ジャッジが 5,3 の順に値を追加するケースです。
| 入力 | 出力 | 説明 |
|---|---|---|
2 |
Q が与えられます。 | |
1 5 |
push クエリです。X=5 が与えられ、キュー 1 の末尾に追加されます。 | |
0 |
移動操作を行う回数は 0 回です。 | |
1 3 |
push クエリです。X=3 が与えられ、キュー 1 の末尾に追加されます。 | |
3 1 2 1 2 2 2 |
移動操作を 3 回行います。5 をキュー 2 へ移動し、3 をキュー 2 へ移動し、キュー 2 の先頭の 5 を同じキューの末尾へ移動します。これにより、キュー 2 は先頭から 3,5 の順になります。 | |
2 |
pop クエリです。 | |
2 |
キュー 2 を選びます。その後、ジャッジがキュー 2 の先頭の 3 を取り除きます。 | |
2 |
pop クエリです。 | |
2 |
キュー 2 を選びます。その後、ジャッジがキュー 2 の先頭の 5 を取り除きます。 |
Score : 800 points
Problem Statement
This is an interactive problem (in which your program interacts with the judge via input and output).
There are five queues numbered 1 through 5. Initially, all queues are empty.
The judge gives you the following two types of queries, Q times each, for a total of 2Q times.
- push query: The judge gives you an integer X, which is appended to the back of queue 1. The integers X given in the push queries are all distinct. Then, you may perform the following move operation zero or more times.
- move operation: Choose integers i,j satisfying 1 \le i,j \le 5, remove the value at the front of queue i, and append it to the back of queue j. Here, you cannot choose an empty queue as i. It is not required that i\ne j.
- pop query: The judge gives this query only when at least one queue is non-empty. You choose an integer i satisfying 1 \le i \le 5. At this point, queue i must be non-empty, and the value at its front must be the minimum among all the values currently contained in the five queues. Then, the judge removes the value at the front of queue i.
You may perform the move operation at most 10^5 times in total. Create a program that correctly responds to all queries.
Constraints
- 1 \le Q \le 5000
- 1 \le X \le 10^9
- The values X appended in the push queries are all distinct.
- The push query and the pop query are each given Q times.
- At the time each pop query is given, at least one queue is non-empty.
- All input values are integers.
Interaction
This problem is interactive.
First, the judge gives a positive integer Q in the following format:
Q
Then, perform the following interaction 2Q times. In each round, the judge first gives a push query or a pop query.
A push query is given in the following format:
1 X
A pop query is given in the following format:
2
(If your response to the previous query was invalid, -1 will be given from Standard Input instead of a query. In this case, immediately terminate your program normally. However, if your first invalid output is your response to the 2Q-th query, no further input will be given after that.)
If a push query is given, let k be the number of move operations you perform, and let i_r,j_r be the queue numbers chosen in the r-th move operation; output k+1 lines in the following format. Be sure to add a newline at the end of the output.
k i_1 j_1 i_2 j_2 \vdots i_k j_k
If a pop query is given, output the number i of the queue from which to remove the front value, in the following format. Be sure to add a newline at the end of the output.
i
Notes
- Each time you output a response to a query, flush Standard Output after adding a newline at the end. Otherwise, the judge result may be TLE.
- If you receive
-1as input from the judge, immediately terminate your program normally. If you do so, the judge result will be WA; otherwise, the judge result is indeterminate. - Extra newlines are regarded as malformed output, so do not output them.
- After you finish responding to the 2Q queries, immediately terminate your program. Otherwise, the judge result will be indeterminate.
- The judge for this problem is not adaptive. Before the interaction begins, the judge determines the types and order of the queries, and the integer X given in each push query.
Sample Interaction
Below is a case where Q=2, and the judge appends the values 5,3 in this order.
| Input | Output | Description |
|---|---|---|
2 |
Q is given. | |
1 5 |
A push query. X=5 is given, and it is appended to the back of queue 1. | |
0 |
Perform zero move operations. | |
1 3 |
A push query. X=3 is given, and it is appended to the back of queue 1. | |
3 1 2 1 2 2 2 |
Perform three move operations. Move 5 to queue 2, move 3 to queue 2, and move the front value 5 of queue 2 to the back of the same queue. As a result, queue 2 contains 3,5 from front to back. | |
2 |
A pop query. | |
2 |
Choose queue 2. Then, the judge removes the front value 3 of queue 2. | |
2 |
A pop query. | |
2 |
Choose queue 2. Then, the judge removes the front value 5 of queue 2. |
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,1 と j=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. ジャッジ方法
以下の手順でジャッジを行います。
-
正整数 N と、0 と 1 からなる長さ N の数列 S=(S_1,S_2, \ldots ,S_N) を決める。これらはテストケースごとに固定である。
-
あなたが出力したオートマトンの設計を受け取る。
-
空の数列 T を用意し、初期状態から N+D-1 ターンのシミュレーションを行う。 具体的には、各 k=1,2,\ldots,N+D-1 について、k ターン目には以下の処理を順に行う。
- k \le N ならば、送信マス (R_s,C_s) の状態を S_k に変更する。
- グリッドに対して 1 回の更新操作を行う。
- D \le k < D+N ならば、受信マス (R_t,C_t) の状態を T の末尾に追加する。
-
シミュレーションの終了後、S=T ならば正解、そうでなければ不正解となる。
N,S によらず正解となるオートマトンの設計が存在することは保証されますが、この問題ではジャッジの実装上、N および S はテストケースファイルごとに固定されており、N が 300 以下のケースでのみジャッジされます。
制約
- ジャッジで使用される N は 1 以上 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.
-
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.
-
Receive the design of the automaton that you output.
-
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.
- If k \le N, change the state of the sending cell (R_s,C_s) to S_k.
- Perform one update operation on the grid.
- If D \le k < D+N, append the state of the receiving cell (R_t,C_t) to the end of T.
-
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.