#P10396. 健将青蛙……

    ID: 10621 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2024洛谷原创提交答案Special JudgeO2优化洛谷月赛

健将青蛙……

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 300300 (indexed from 13001\sim 300), initially all 00. Each cell stores a 3232-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 11, then move one step in a specified direction.
  • Compare: compare the values at indices i,ji,j 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:

  1. Read a,ba,b into the initial memory indices 1,21,2, and output a+ba+b. It is guaranteed that 0a,b1000\leq a,b\leq 100.
  2. Read aa into the initial memory index 11, and output 2a2^a. It is guaranteed that 0a200\leq a\leq 20.
  3. Read aa into the initial memory index 11, and output a2a^2. It is guaranteed that 1a10001\leq a\leq 1000.
  4. Read a,ba,b into the initial memory indices 1,21,2, and output aba\oplus b. It is guaranteed that 0a,b<2190\leq a,b<2^{19}.
  5. Read n=50,a1,a2,ann=50,a_1,a_2\dotsc,a_n into the initial memory indices 1511\sim 51, and output a1ana_1\sim a_n sorted in nondecreasing order. It is guaranteed that 0ai1000\leq a_i\leq100.
  6. Read n=30,u1,v1,un1,vn1n=30,u_1,v_1\dotsc,u_{n-1},v_{n-1} into the initial memory indices 1591\sim 59, representing a tree with nn nodes and n1n-1 edges ui,viu_i,v_i. 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 1ui,vin1\leq u_i,v_i\leq n.

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 5×107\leq 5\times 10^7.

Output Format

This problem is judged with Special Judge.

For the 66 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 n,mn,m, indicating that the grid size is nn rows and mm columns. You must ensure that n×m107n\times m\leq 10^7.

The second line outputs a positive integer kk, the number of special nodes. Here 1kn×m1\leq k \leq n \times m.

In the next kk lines, each line has the following format:

The first two output integers x,yx,y indicate that the special node is located at row xx, column yy, where 1xn,1ym1\leq x\leq n,1\leq y\leq m, and all (x,y)(x,y) 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 ii to increment/decrement, where 1i3001\leq i\leq 300. Finally output a character from LRUD indicating the moving direction (corresponding to left, right, up, down; the same below).
  • If it is a compare node, output c, then two integers i,ji,j indicating the indices to compare; you need to ensure 1i,j3001\leq i,j\leq 300. Finally output two characters from LRUD, indicating the moving direction when the value at index ii is greater than the value at index jj, and when the value at index ii is less than or equal to the value at index jj, respectively.
  • If it is an input node, output i, then output a character from LRUD indicating the moving direction.
  • If it is an output node, output o, then output an integer pp indicating the output size, followed by pp pairwise distinct integers a1apa_1\sim a_p indicating the memory indices you want to output. You need to ensure 1p,ai3001\leq p,a_i\leq 300.

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 a,ba,b and outputs max(a,b)\max(a,b).


Scoring: If your output format is wrong or the result is wrong, you get 00 points. Otherwise, for each test point, your score is related to the size of n×mn\times m. Each test point has 22 scoring parameters c1,c2c_1,c_2. If n×mc1n\times m\leq c_1, you get full points for that test point; otherwise, if c1<n×mc2c_1< n\times m\leq c_2, you get 60%60\% of the points; otherwise, you get 40%40\% of the points.

Task Id c1=c_1 = c2=c_2 = pts
1 66 99 1010
2 99 1212 1515
3 1010
4 3535 4848 2020
5 499499 999999
6 3×1033\times 10^3 3×1053\times 10^5

The distributed 附件.zip contains files that are helpful for solving the problem.

  • ./checker/checker.cpp, whose implementation is roughly the same as the Special Judge used in evaluation.
  • ./toy/index.html can be used in a browser. It is the web-based visualization tool for this problem; see the internal instruction for usage.

Translated by ChatGPT 5