#P1737. [NOI2016] 旷野大计算

    ID: 699 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学2016NOI 系列提交答案Special Judge

[NOI2016] 旷野大计算

Description

With the development of human computer technology, computers keep getting more powerful, which makes the Flea King very envious.

One day, the Flea King issued a decree: vigorously develop the Flea Kingdom’s computer industry! However, the Flea Kingdom has not undergone an industrial revolution and cannot manufacture the components needed for electronic computers. But the Flea King came up with a brilliant idea: treat each flea as a computing node, and each flea only performs a specific small task.

The Flea King led nn fleas to a wilderness, arranged them as computing nodes, and numbered them from 11 to nn. Each computing node takes the results of some (possibly 00) other computing nodes as input and computes an output. In addition, the Flea King has a giant terminal that can input and output data. This terminal and all the computing nodes together form a computer.

Let the output of the tt-th computing node be xtx_t. The operation of this node can be one of the following types:

::cute-table{tuack}

Name Operator (Type) Operands Result
Input node I None Read a real number from the terminal as xtx_t
Output node O ii xt=xix_t = x_i, and output xtx_t to the terminal
Addition node + i,ji, j xt=xi+xjx_t = x_i + x_j
Offset node C i,ci, c xt=xi+cx_t = x_i + c
Negation node - ii xt=xix_t = -x_i
Left shift node < i,ki, k xt=xi2kx_t = x_i \cdot 2^k
Right shift node > xt=xi2kx_t = x_i \cdot 2^{-k}
S-type node S ii xt=s(xi)x_t = s(x_i)
Comparison node P i,ji, j $x_t=\begin{cases}-1 &x_ix_j\\\end{cases}$
Max node M $x_t=\begin{cases}x_i &x_i>x_j\\x_j &x_i \leq x_j\end{cases}$
Multiplication node * xt=xixjx_t = x_i \cdot x_j

Here, s(x)s(x) is defined as follows (ee is the base of the natural logarithm, approximately 2.7182818284590452.718281828459045\ldots):

s(x)=11+exs\left ( x \right )=\frac{1}{1+e^{-x}}

The graph of s(x)s(x) is shown below:

In the table above, the operand indices i,ji, j must both be less than the current node index tt. Thus, when the Flea King gives the order, the fleas can obtain inputs and compute outputs in order from small index to large. Each flea’s computational precision is limited: they can only be accurate to 9090 digits after the decimal point, and any excess is rounded. Similarly, the fractional part of the operand cc in the table above cannot exceed 9090 digits. Moreover, in left shift and right shift nodes, the operand kk must be a non-negative integer and cannot exceed 10410^4.

After arranging the fleas, the ambitious Flea King decided to test the computational capability of this flea-based computer. The Grasshopper Minister (guoguo, pinyin) presented 10 computational tasks to the Flea King. Each task requires reading input from the terminal, performing intermediate computations, and then outputting the result using an output node. The specific tasks are as follows:

::cute-table{tuack}

ID Input Input constraints Output
11 a,ba, b a,b109\lvert a \rvert, \lvert b \rvert \le 10^9, fractional part no more than 99 digits 2a2b-2a - 2b
22 aa a109\lvert a \rvert \le 10^9, fractional part no more than 99 digits 11+e17a\dfrac{1}{1+e^{17a}}
33 $\begin{cases}-1 & a \lt 0 \\ 0 & a = 0 \\ 1 & a \gt 0\end{cases}$
44 a\lvert a \rvert, i.e., the absolute value of aa
55 a1,,a32a_1, \dots, a_{32} a1,,a32{0,1}a_1, \dots, a_{32} \in \{0, 1\} Read a1,,a32a_1, \dots, a_{32} from left to right as a binary integer, with most significant bit on the left and least significant bit on the right, and output its value
66 aa 0a<2320 \le a \lt 2^{32}, aa is an integer Output 3232 integers: the binary representation of aa from most significant bit to least significant bit (pad with leading zeros to length 3232 if necessary)
77 a,ba, b 0a,b<2320 \le a, b \lt 2^{32}, a,ba, b are integers The bitwise XOR of aa and bb
88 aa a109\lvert a \rvert \le 10^9, fractional part no more than 99 digits a10\dfrac{a}{10}
99 a1,,a16a_1, \dots, a_{16} $\lvert a_1 \rvert, \dots, \lvert a_{16} \rvert \le 10^9$, fractional part no more than 99 digits Output 1616 real numbers: the result of sorting a1,,a16a_1, \dots, a_{16} in nondecreasing order
1010 a,b,ma, b, m 0a,b<2320 \le a, b \lt 2^{32}, 1m<2321 \le m \lt 2^{32}, a,b,ma, b, m are integers The remainder of aba \cdot b divided by mm

The Flea King found that he did not have enough ability to design such a computer. So he turned to you, a contestant at NOI. Please design the type and operands of each computing node in order to complete the 10 tasks given by the Grasshopper Minister, while using as few computing nodes as possible.

Input Format

All input testdata nodes1.in \sim nodes10.in correspond to the 10 computational tasks respectively.

Each input file contains a single integer indicating the ID of the computational task to solve.

Since they are only for internal judge use, Luogu does not provide downloads for the testdata of this problem. Generate them yourself if needed.

Output Format

The output files are nodes1.out \sim nodes10.out, corresponding to the respective input files.

For each input file, output several lines; the ii-th line describes the ii-th computing node.

To describe each computing node, first output one character indicating the node type, followed by its built-in parameters in order. Use a single space between the character and numbers, and between numbers.

The number of output lines must not exceed 10410^4.

1
I
+ 1 1
- 2
I
+ 4 4
- 5
+ 3 6
- 7
- 8
O 9

Hint

The sample output is one possible construction for the first task. It uses 1010 computing nodes and earns 33 points.

We provide ten scoring files nodes1.ans \sim nodes10.ans, corresponding to each computational task.

Each scoring file contains 1010 lines. The ii-th line contains one scoring parameter wiw_i, whose meaning is given below.

Each test point is scored independently, with 1010 points per test point.

If your output format is invalid or parameters do not meet the problem’s requirements, you get 00 points.

Otherwise, the judge determines correctness as follows:

  • The judge will generate several groups of inputs and feed them into your constructed computer.
  • If for any input group, during computation on your constructed computer, the absolute value of some node’s result exceeds 10100010^{1000}, you get 00 points.
  • If any value in your output differs from the expected output by more than 10910^{-9}, your output is considered incorrect and you get 00 points.
  • Otherwise, we consider your computer able to complete the given task, and your score is determined as follows.

For each test point, we set 1010 scoring parameters w1,w2,w3,,w9,w10w_1, w_2, w_3, \ldots, w_9, w_{10}.

Suppose you used nn computing nodes. Your score is given by the table below:

::cute-table{tuack}

Score Condition Score Condition
10 nw10n \le w_{10} 5 nw5n \le w_5
9 nw9n \le w_9 4 nw4n \le w_4
8 nw8n \le w_8 3 nw3n \le w_3
7 nw7n \le w_7 2 nw2n \le w_2
6 nw6n \le w_6 1 nw1n \le w_1

If none of the conditions in the table are met, you get 00 points. If multiple conditions are met, take the highest score.

In addition, the cost of using the Comparison node, Max node, and Multiplication node is extremely expensive. Therefore, for each type among these three that you use, 44 points will be deducted from your score on that test point.

Note that the deduction is by the number of node types used, not by usage count. For example, using the Comparison node multiple times only deducts 44 points. If you used both the Comparison node and the Multiplication node, even if each is used once, 88 points will be deducted.

A test point’s score will be deducted to at most 00; even if the available score is insufficient, the score will not go negative.

Translated by ChatGPT 5