#P10396. 健将青蛙……
健将青蛙……
Background
After breaking out of prison, the little frog started to focus on physical training.
He became a sports champion.
His story continues...
Problem Description
This is an output-only problem.
Your brain needs training.
You are a bot. You have a memory array of size (indexed from ), initially all . Each cell stores a -bit integer (i.e., int in C++).
You need to construct a grid graph. Some grid nodes contain an instruction, and the robot operates and moves according to these instructions.
In the following, nodes that have instructions are called special nodes.
The instructions on nodes are of the following types:
- Increment/Decrement: increase or decrease the integer at some memory index by , then move one step in a specified direction.
- Compare: compare the values at indices in memory, then move one step in a specified direction based on the comparison result.
- Input: the robot starts from here, then moves one step in a specified direction. This node must not be visited more than once.
- Output: when the robot reaches this node, it stops and outputs the values at specified positions.
The input node and the output node must both exist and be unique.
Tasks:
- Read into the initial memory indices , and output . It is guaranteed that .
- Read into the initial memory index , and output . It is guaranteed that .
- Read into the initial memory index , and output . It is guaranteed that .
- Read into the initial memory indices , and output . It is guaranteed that .
- Read into the initial memory indices , and output sorted in nondecreasing order. It is guaranteed that .
- Read into the initial memory indices , representing a tree with nodes and edges . Output the diameter length of the given tree (defined as the number of edges on the longest simple path in the tree). It is guaranteed that .
You must ensure that the robot can reach the output node starting from the input node, and it will not visit any non-special node along the way, and the number of moves is .
Output Format
This problem is judged with Special Judge.
For the tasks given in the statement, you need to submit your output files robot1.out~robot6.out respectively.
For each file, your output should have the following format:
The first line outputs two positive integers , indicating that the grid size is rows and columns. You must ensure that .
The second line outputs a positive integer , the number of special nodes. Here .
In the next lines, each line has the following format:
The first two output integers indicate that the special node is located at row , column , where , and all are distinct. Then, depending on the node type, output different contents:
- If it is an increment node, output
+; if it is a decrement node, output-. Then output an integer indicating the memory index to increment/decrement, where . Finally output a character fromLRUDindicating the moving direction (corresponding to left, right, up, down; the same below). - If it is a compare node, output
c, then two integers indicating the indices to compare; you need to ensure . Finally output two characters fromLRUD, indicating the moving direction when the value at index is greater than the value at index , and when the value at index is less than or equal to the value at index , respectively. - If it is an input node, output
i, then output a character fromLRUDindicating the moving direction. - If it is an output node, output
o, then output an integer indicating the output size, followed by pairwise distinct integers indicating the memory indices you want to output. You need to ensure .
You need to ensure that among the special nodes you provide, the input node and the output node must exist and be unique.
2 3
4
1 1 i R
1 2 c 1 2 R D
1 3 + 2 L
2 2 o 1 2
Hint
The sample above gives a program that reads and outputs .
Scoring: If your output format is wrong or the result is wrong, you get points. Otherwise, for each test point, your score is related to the size of . Each test point has scoring parameters . If , you get full points for that test point; otherwise, if , you get of the points; otherwise, you get of the points.
| Task Id | pts | ||
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 |
The distributed 附件.zip contains files that are helpful for solving the problem.
./checker/checker.cpp, whose implementation is roughly the same as theSpecial Judgeused in evaluation../toy/index.htmlcan be used in a browser. It is the web-based visualization tool for this problem; see the internalinstructionfor usage.
Translated by ChatGPT 5