#P16347. Wisdom, Computer Science, and the E.T.C.

    ID: 18429 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>提交答案Special Judge

Wisdom, Computer Science, and the E.T.C.

Background

Source of this problem: https://www.luogu.com.cn/contest/314899.

:::warning{open} Since the problem setter was rushing to write the problem, most of the content may be relatively simple.

If you solve it instantly, you can make a harder version. :::

::::info[Advertisement] There are many types of companies that can transport things. For example, some of them can transport food, we call them food transportation companies. Similarly, there are material transportation companies, factory transportation companies, furniture transportation companies, and the Energy Transportation Company, E.T.C.

:::align{center} The E.T.C. Logo :::

Bob, one of my friends, works in E.T.C. "E.T.C. has a good working environment, excellent dining, adequate compensation, and plenty of leisure time. If you work there, when you finish all your work and walk out of the gate at 3 p.m., you will definitely feel happy and comfortable," Bob says.

Above is some introduction about E.T.C. But don't pay too much attention to the descriptions what are all fictional. The problem statement below is not related to E.T.C. or the text above. ::::

To ensure image quality, please make sure your computer has downloaded the Caviar Dreams font.

Problem Description

In some world, there is something called energy, which exists in certain materials. But unlike our world, sometimes energy can detach from matter and appear by itself. In this case, we usually use EE to represent the amount of energy, where EE is any integer.

Sometimes, some energies gather at the same place. Then these energies merge with each other to form a larger energy, and the amount of the new energy equals the sum of the amounts of all those energies.

Meanwhile, there is a company called the Energy Transportation Company, abbreviated as E.T.C. In the early days of E.T.C., its business only included energy storage transfer and energy delivery. As time went on and various supply demands increased, E.T.C. gradually became a IoT company a mature multifunctional company with a complete system.

E.T.C. has a new emerging industry: using energy to compute. Researchers invented a set of machines. Some of these machines can generate energy out of thin air, some can double energy, and some can even convert energy into negative energy of the corresponding amount.

Negative energy of amount FF can be understood as energy of amount F-F. In other words, when negative energy merges with energy, they cancel each other at the same rate until one of them disappears.

A few days ago, E.T.C. purchased this set of machines.

We place all machines that are needed into the newly opened computing workshop, number the machines from 11 to NN, and connect them with energy pipelines. Among them, there are some special machines that can interact with workers for input and output, making it convenient for people to operate. This set of machines and energy pipelines, which includes input, output, and computational processing, forms a structure that can handle some relatively fixed operations. We call it a program.

In a program, every machine operates at the same frequency, and we call this frequency a round. In each round, based on the sum of all energies input to it in the previous round and on the machine’s own settings, a machine outputs a certain amount of energy to one or more specific machines. We define the time when the program starts running as round 00, and then we can describe the operations performed by each machine at a certain time.

Let the current round number be tt. The input to the input machine with index id\textrm{id} in round tt is denoted by It,idI_{t,\textrm{id}}. The total output received by machine ii from other machines in round tt is denoted by Et,iE_{t,i}. The operation of outputting energy of amount XX to machine out\textrm{out} so that it will be received by machine out\textrm{out} in the next round is denoted by XoutX \to \textrm{out}.
Initially, all E0,iE_{0,i} are 00.
Then, machine ii’s operation in round tt can be divided into the following types:

Name Symbol Operands Computation
Input machine I id out It,idout{I_{t,\textrm{id}} \to \textrm{out}}
Output machine O None There must be exactly one in a program. If Et,i0{E_{t,i} \not= 0}, terminate the whole program and output Et,i{E_{t,i}} as the total output of the program. It is guaranteed that the answer is not 0\mathbf 0.
Energy-producing machine P amount out ${\begin{cases} E_{t,i} + \textrm{amount} \to \textrm{out} & E_{t,i} \ge 0 \\ \min(E_{t,i} + \textrm{amount}, 0) \to \textrm{out} & E_{t,i} < 0 \end{cases}}$
Energy-reducing machine R ${\begin{cases} \max(E_{t,i} - \textrm{amount}, 0) \to \textrm{out} & E_{t,i} \ge 0 \\ E_{t,i} - \textrm{amount} \to \textrm{out} & E_{t,i} < 0 \end{cases}}$
Negation machine N out Et,iout{-E_{t,i} \to \textrm{out}}
Copy machine C out1 out2 Et,iout1{E_{t,i} \to \textrm{out}_1}, Et,iout2{E_{t,i} \to \textrm{out}_2}
Delay machine T out It has two states: idle and working. Initially it is idle. If it is idle and Et,i0{E_{t,i} \not= 0}, then it becomes working. In round t+abs(Et,i){t + \operatorname{abs}(E_{t,i})}, it switches from working back to idle, and performs: ${\begin{cases}\sum_{j = t + 1}^{t + E_{t,i}}{E_{j,i}} \to \textrm{out} & E_{t,i} > 0 \\ E_{t-E_{t,i},i} \to \textrm{out} & E_{t,i} < 0 \end{cases}}$
Decision machine D x1 out1 x2 out2 x3 out3 ${\begin{cases} x_1 \to \textrm{out}_1 & E_{t,i} < 0 \\ x_2 \to \textrm{out}_2 & E_{t,i} = 0 \\ x_3 \to \textrm{out}_3 & E_{t,i} > 0 \\ \end{cases}}$

All parameters above must satisfy $1 \le \textrm{out}, \textrm{out}_1, \textrm{out}_2, \textrm{out}_3 \le N$, $0 \le \textrm{amount}, |x_1|, |x_2|, |x_3| \le 10^9$.

In addition, if there are MM required input machines, then all id\textrm{id} must satisfy 1idM1 \le \textrm{id} \le M, and each number in 1M1 \sim M appears exactly once.

In particular, machines have an upper limit on recognition ability. If the absolute value of the total output Et,iE_{t,i} received by machine ii in round tt is greater than 10910^9, then Et,iE_{t,i} will be rounded to the number with the same sign and absolute value 10910^9.

After accumulating some experience, we found that in many cases it is hard to adjust the program structure to match the input speed. Later, we actively negotiated with clients and increased the flexibility of our input. Now we can set a positive integer input factor IFI_F, which indicates how much the input is slowed down. Let the initial input matrix be UU. Then the actual input matrix II satisfies ItIF,i=Ut,iI_{t \cdot I_F, i} = U_{t, i}, and all unspecified positions are 00.

Now we hand over the task of program design to you. You need to solve the tasks below, while keeping the number of machines and the time to produce the output small enough:

:::info[Task 1]{open} Input xx at I0,1I_{0,1}, output 114514114514. 1x1091 \le |x| \le 10^9. :::

:::info[Task 2]{open} Input xx at I0,1I_{0,1}, then input yy at I1,1I_{1,1}, output x+yx + y. 1x,y1001 \le |x|,|y| \le 100. :::

:::info[Task 3]{open} Input x,yx,y at I0,1I_{0,1} and I0,2I_{0,2} respectively, output x×yx \times y. 1x,y1001 \le x,y \le 100. :::

:::info[Task 4]{open} Input x,yx,y at I0,1I_{0,1} and I0,2I_{0,2} respectively, output min(x,y)\min(x,y). 1x,y1001 \le x,y \le 100. :::

:::info[Task 5]{open} Input xx at I0,1I_{0,1}, output the xx-th term of the sequence ${A = \{1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12, 13\}}$, i.e., AxA_x. 1xA1 \le x \le |A|. :::

:::info[Task 6]{open} For each integer ii with 0i<200 \le i < 20, input aia_i at Ii,1I_{i,1}, output 0i<20219iai\sum_{0 \le i < 20}{2^{19-i}a_i}. ai{0,1}a_i \in \{0,1\}. :::

:::info[Task 7]{open} Input nn at I0,1I_{0,1}, input kk at I0,2I_{0,2}, then for all integers ii with 1in1 \le i \le n, input aia_i at Ii,3I_{i,3}, output kiai\sum_{k \mid i}a_i. 1kn1001 \le k \le n \le 100, 1ai1001 \le a_i \le 100. :::

:::info[Task 8]{open} Input nn at I0,1I_{0,1}, then for all integers ii with 1in1 \le i \le n, input aia_i at Ii,2I_{i,2}, output max(a1,a2,,an)\max(a_1,a_2,\dots,a_n). 1n,ai1001 \le n, a_i \le 100. :::

:::info[Task 9]{open} Input nn at I0,1I_{0,1}, input kk at I0,2I_{0,2}, then for all integers ii with 1in1 \le i \le n, input aia_i at Ii,3I_{i,3}, output the smallest index ii such that ai=ka_i = k. It is guaranteed that there exists exactly one ai=ka_i = k. 1n1001 \le n \le 100, 1k,ai1001 \le k, a_i \le 100. :::

Input Format

The input contains only one line with one integer, representing the index of the task to solve. In particular, in the sample, the index is 00.

Output Format

On the first line, output two positive integers: the number of machines you use NN and the input factor IFI_F you specify.

In the next NN lines, line ii is used to describe machine ii.

When describing each machine, first output an uppercase letter indicating the type of the computing node, then output several non-negative integers as the machine parameters in the order given in the table above. Separate the uppercase letter and numbers, and numbers and numbers, with spaces.

0
2 1
I 1 2
O

Hint

The sample output is a program that outputs I0,1I_{0,1} in round 11.


In the provided file wisdom.zip, we provide nine scoring files wisdom1.ans to wisdom9.ans, corresponding to the nine tasks.

Each scoring file has 66 lines in total. Line i+1i + 1 contains two scoring parameters nin_i and tit_i. Their meanings will be given below.

In this problem, each test point is scored independently, and each test point is worth 4040 points.

If the contestant’s output has NN greater than n5n_5, has an invalid output format, or has parameters that do not meet the requirements of the statement, then the score is 00.

Otherwise, the contestant’s output is judged to be correct according to the following rules:

  • First, the judge generates several groups of input data, puts the input data into the matrix II according to the format, and then runs the program.
  • If your program still does not output an answer after running for t5t_5 rounds, or if the output is different from the expected output, the score is 00.
  • Otherwise, we consider your program to have completed this task.

For each test point, we set 1212 scoring parameters: n0,n1,n2,n3,n4,n5n_0,n_1,n_2,n_3,n_4,n_5 and t0,t1,t2,t3,t4,t5t_0,t_1,t_2,t_3,t_4,t_5.

When your program can complete the corresponding task, suppose your program has NN machines and outputs at the latest in round TT under the testdata. We then find the smallest i,j{i,j} such that Nni{N \le n_i} and Ttj{T \le t_j}. Then your program gets 4×min(10,12ij){4 \times \min\left(10, 12 - i - j\right)} points on this test point.

Note that because two scoring parameters take effect at the same time, to get more points you must make a trade-off between your program’s efficiency and size.

The file wisdom.zip includes a simulator simulator.cpp. The Special Judge implementation is basically the same as this file. You can check the code directly for usage, and we will not repeat it here.

Translated by ChatGPT 5