#P8679. Multiple Problems: Team Formation, Year String, Sequence Evaluation, Number Decomposition, and Maze
Multiple Problems: Team Formation, Year String, Sequence Evaluation, Number Decomposition, and Maze
Multiple Problems: Team Formation, Year String, Sequence Evaluation, Number Decomposition, and Maze
This contest problem consists of five subproblems:
Problem A (Team Formation): As the coach of a basketball team, you are given a list of players. Each player has a rating for acting in positions 1 through 5. Choose exactly one player for each position so that the sum of the ratings is maximized.
Problem B (Year String): Each letter from A to Z corresponds to numbers 1 to 26 respectively. For numbers beyond 26, a multi‑letter string is used (just like Excel columns). For example, AA represents 27, AB represents 28, and so on. Compute the string corresponding to the number (2019).
Problem C (Sequence Evaluation): Consider the sequence defined by (F(1)=F(2)=F(3)=1) and for (n\ge 4), (F(n)=F(n-1)+F(n-2)+F(n-3)). Compute the last four digits (in (\LaTeX) format, i.e. as an integer) of (F(20190324)).
Problem D (Number Decomposition): Express (2019) as the sum of three distinct positive integers, with the restriction that none of the integers contains the digit 2 or 4. Count the number of different decompositions (order does not matter).
Problem E (Maze): You are given a maze represented by a (30 \times 50) grid. Cells marked with 0 are passable and those with 1 are obstacles. The maze entrance is located at the top‑left corner and the exit at the bottom‑right corner. Movements are allowed in the four cardinal directions (up, down, left, right). Among all shortest paths from the entrance to the exit, output the lexicographically smallest one under the order (D < L < R < U).
Input Format: The input begins with a single uppercase letter (A, B, C, D, or E) indicating which subproblem to solve, followed by the specific input for that subproblem (see Input Description below).
Note: Each subproblem is a result‑filling problem. Your program should output exactly the required answer for the specified subproblem.
inputFormat
The first line of input contains a single uppercase letter representing the subproblem to solve.
For Problem A: The next line contains an integer (n) (the number of players), followed by (n) lines. Each of these lines contains 6 integers: the first integer is the player's id (which can be ignored) and the next 5 integers represent the ratings for positions 1 through 5.
For Problem B: There is no additional input.
For Problem C: There is no additional input.
For Problem D: There is no additional input.
For Problem E: The next 30 lines each contain a string of 50 characters (each character is either '0' or '1') representing the maze grid.
outputFormat
Output a single line containing the answer for the specified subproblem:
- For Problem A: Output the maximum possible sum of selected ratings.
- For Problem B: Output the corresponding uppercase letter string for the number (2019).
- For Problem C: Output the last 4 digits of (F(20190324)), computed modulo 10000.
- For Problem D: Output the number of valid decompositions of (2019).
- For Problem E: Output a string (composed of the characters D, L, R, U) representing the lexicographically smallest shortest path from the entrance to the exit.
sample
A
5
1 10 2 3 4 5
2 5 4 3 2 1
3 6 7 8 9 10
4 1 2 3 4 5
5 10 10 10 10 10
37
</p>