P5285 [Twelve Provinces Joint Exam 2019] Cheating to Pass the Samples

Background

This is a **traditional problem**. “What function does my program need to implement?...” “I don’t know either...” “Huh? Then how am I supposed to write it?...” “Someone has already written the tests for you. As long as you pass these tests, you will be fine...” “Huh?...” “All the testdata are in the problem directory. Please make backups to avoid accidental deletion!” “This...” “Oh, I can also tell you the input format... but since the data are complete anyway, knowing the input format may not be very useful...”

Description

The problem data are provided in the attached files.

Input Format

The first line contains a string, indicating the function ID of the software feature that needs to be run. The more similar two IDs are, the closer the algorithms for the corresponding two functions are. Then, depending on the function, there may be input of any length. See the documentation for each function for details.

Output Format

See the documentation for each function for details.

Explanation/Hint

#### Subtasks “Where is the ‘documentation for each function’?” “I don’t have it either, just like I don’t have a problem statement...” “Alright... then can I just hardcode a table?...” “**The code length limit is $\bold{102400}$ bytes** ($100$KB). You definitely can’t hardcode everything! However, if needed, you may hardcode some small tables...” “Um...” “Also, we will score your program separately for each test point, and sum them up to get the total score. By tradition, each test point gives full marks if correct, and $0$ points if wrong. **The points of each test point are not all the same, and the points, order, and difficulty of test points have no necessary relationship**.” | Test Point | Function ID | Points | | :-------: | :-------: | :-------: | | $1$ | $\texttt{1\_998244353}$ | $4$ | | $2$ | $\texttt{1\_998244353}$ | $4$ | | $3$ | $\texttt{1\_998244353}$ | $4$ | | $4$ | $\texttt{1?}$ | $7$ | | $5$ | $\texttt{1?+}$ | $9$ | | $6$ | $\texttt{1wa\_998244353}$ | $6$ | | $7$ | $\texttt{1wa\_998244353}$ | $7$ | | $8$ | $\texttt{2p}$ | $4$ | | $9$ | $\texttt{2p}$ | $6$ | | $10$ | $\texttt{2p}$ | $8$ | | $11$ | $\texttt{2u}$ | $5$ | | $12$ | $\texttt{2u}$ | $6$ | | $13$ | $\texttt{2u}$ | $9$ | | $14$ | $\texttt{2g}$ | $5$ | | $15$ | $\texttt{2g}$ | $7$ | | $16$ | $\texttt{2g?}$ | $9$ | #### Hint When you use the `int` type in C/C++, if an overflow occurs, a likely situation is that under the assumption of congruence modulo $2^{32}$, a reasonable value within the `int` range is taken. For example, when computing $2147483647 + 2$, it is quite likely to get $-2147483647$. However, the C/C++ standard classifies this situation as “undefined behavior”. When your program tries to evaluate an `int` operation that would overflow, besides the result above, the compiler may also make your program produce an incorrect result, enter an infinite loop, crash at runtime, etc. All of these are compliant with the C/C++ standard. If your program wants to make use of the natural overflow behavior of `int`, please switch to `unsigned` operations. For example, rewrite `a + b` as `(int) ((unsigned) a + (unsigned) b)`, to avoid unexpected errors. Translated by ChatGPT 5