#P5694. [NOI2001] 陨石的秘密

[NOI2001] 陨石的秘密

Problem Description

In the year 11380 AD, a huge meteorite fell in Antarctica. Then disaster struck, and a series of abnormal phenomena appeared on Earth. When people were extremely anxious, a Chinese scientific expedition to Antarctica arrived at the scene. After some investigation, the scientists found several lines of ciphertext carved on the meteorite, and each line contains 5 integers:

1 1 1 1 6
0 0 6 3 57
8 0 11 3 2845

The famous scientist SS discovered that these ciphertexts are actually the results of a complex operation. To make this operation easier to understand, he defined an SS expression:

  1. An SS expression is a string consisting only of {, }, [, ], (, ).
  2. The empty string is an SS expression.
  3. If A A is an SS expression and A A does not contain the characters {, }, [, ], then (A) (A) is an SS expression.
  4. If A A is an SS expression and A A does not contain the characters {, }, then [A] [A] is an SS expression.
  5. If A A is an SS expression, then {A} \{A\} is an SS expression.
  6. If A A and B B are both SS expressions, then AB AB is also an SS expression.

The depth D(E) D(E) of an SS expression E E is defined as follows:

$$\scriptstyle{ D(E) = \begin{cases} \scriptstyle{0}, & \scriptstyle{\text{if } E \text{ is the empty string}} \\ \scriptstyle{D(A) + 1}, & \scriptstyle{\text{if } E = (A) \text{ or } E = [A] \text{ or } E = \{A\}, \text{ where } A \text{ is an SS expression}} \\ \scriptstyle{\max(D(A), D(B))}, & \scriptstyle{\text{if } E = AB, \text{ where } A, B \text{ are SS expressions}} \end{cases} }$$

For example, the depth of (){()}[] is 2 2 .

The complex operation in the ciphertext is performed as follows:

Let the first 4 4 numbers in each line of the ciphertext be L1,L2,L3,D L_1, L_2, L_3, D in order. Compute the number of all SS strings with depth D D , containing L1 L_1 pairs of {}, L2 L_2 pairs of [], and L3 L_3 pairs of (); then take this number modulo the current year 11380 11380 . This remainder is the 5 5 -th number in that line of the ciphertext, and we call it the “mysterious number”.

The fifth number in some lines of the ciphertext has become blurry, and these numbers are the key to uncovering the meteorite’s secret. Now the scientists hire you to compute this mysterious number.

Input Format

One line with 4 4 integers L1,L2,L3,D L_1, L_2, L_3, D . Adjacent numbers are separated by a single space.

Output Format

One line containing one integer, the mysterious number.

1 1 1 2
8

Hint

0L1,L2,L310 0 \le L_1, L_2, L_3 \le 100D300 \le D \le 30

Translated by ChatGPT 5