K. Downgrade

Codeforces
IDCF10177K
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
The God of Sheep plays an RPG game recently. The game has a level system that records a player's level with a pair of positive integers A and B where A is the major level and B is the minor level. For each major level k, you have to reach minor level Lk in order to upgrade to the next level k + 1. Different major levels may have different number of minor levels. For example, the God of Sheep is currently on level 3-4, and level 3 contains 4 minor levels: 3-1, 3-2, 3-3, and 3-4. Once the God of Sheep upgrades, he will be on level 4-1. The God of Sheep has work to do now. Countless sheep are suffering in slaughter houses, woolsheds, and dairy farms. The God of Sheep has to rescue his fellow sheep citizens. He will be busy with the rescue plan for a couple of days and meanwhile the level of the game will be downgraded each day as a penalty. The downgrade penalty works like this: with each day the God of Sheep not playing the game, his level A-B will firstly be transformed to A minor levels (with minor level B discarded), and then be cast to an equivalent - pair as his new level. For example, suppose both level 1 and level 2 have 2 minor levels, and the God of Sheep is currently on level 3-3. For the first day of his absence, the level will become 2-1, the second day the level will become 1-2, the third day the level will become 1-1, and from the third day on the level will keep the same level as 1-1. The God of Sheep wonders which level will he be when he comes back from the rescue? The first line of the input gives the number of test cases, T. T test cases follow. Each test case contains two lines. The first line contains three integers: A, B and N, indicating the current major level, minor level, and the number of days the God of Sheep will be away from the game. The next line contains A integers: L1, L2, ..., LA indicating the number of minor levels in each major level. For each test case, output one line containing "_Case #x: y-z_", where _x_ is the test case number (starting from 1), _y_ and _z_ are the major level and the minor level when the God of Sheep is back to the game. ## Input The first line of the input gives the number of test cases, T. T test cases follow.Each test case contains two lines. The first line contains three integers: A, B and N, indicating the current major level, minor level, and the number of days the God of Sheep will be away from the game. The next line contains A integers: L1, L2, ..., LA indicating the number of minor levels in each major level. 1 ≤ T ≤ 20. 1 ≤ A ≤ 105. 1 ≤ B ≤ LA. 1 ≤ Li, N ≤ 109. ## Output For each test case, output one line containing "_Case #x: y-z_", where _x_ is the test case number (starting from 1), _y_ and _z_ are the major level and the minor level when the God of Sheep is back to the game. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ j \in \{1, \dots, T\} $: - Let $ n, m, k \in \mathbb{Z} $ denote the number of problems, students, and submissions, respectively. - Let $ S_j = \{(x_i, y_i, z_i, t_i) \mid i \in \{1, \dots, k\}\} $ be the set of submissions, where: - $ x_i \in \{1, \dots, n\} $: problem ID, - $ y_i \in \{1, \dots, m\} $: student ID, - $ z_i \in \{0, 1\} $: correctness (1 = correct, 0 = incorrect), - $ t_i = \text{mm}_i:\text{ss}_i $: submission time in minutes and seconds (total seconds $ \tau_i = 60 \cdot \text{mm}_i + \text{ss}_i $). **Constraints** 1. $ 1 \le T \le 500 $ 2. $ 6 \le n, m \le 30 $, $ 1 \le k \le 10000 $ 3. $ 0 \le \tau_i < 18000 $ (i.e., time < 299:59) 4. $ z_i = 1 \Rightarrow $ no future submission by student $ y_i $ on problem $ x_i $ 5. All $ \tau_i $ are distinct 6. At least one correct submission exists 7. $ \sum_{j=1}^T k_j \le 6 \times 10^5 $ **Objective** For each test case: 1. **First Solvers**: For each problem $ i \in \{1, \dots, n\} $, compute: $$ f_i = \begin{cases} y & \text{if the first correct submission to problem } i \text{ was by student } y \\ -1 & \text{if no correct submission to problem } i \end{cases} $$ 2. **Awards**: Compute four student IDs based on: - **Extreme Programmers Award** ($ a $): Student with **maximum number of solved problems** (lowest ID if tied). - **Steadfast Gurus Award** ($ b $): Student with **minimum total penalty time** (lowest ID if tied). - Penalty = sum over solved problems of $ \tau_{\text{first correct}} + 20 \cdot 60 \cdot (\text{incorrect submissions on that problem before first correct}) $ - **Solid Programmers Award** ($ c $): Student with **maximum number of correct submissions on first attempt** (lowest ID if tied). - **Relentless Programmers Award** ($ d $): Student with **maximum number of incorrect submissions** (lowest ID if tied). Output: $ (f_1, f_2, \dots, f_n) $ on first line; $ (a, b, c, d) $ on second line.
API Response (JSON)
{
  "problem": {
    "name": "K. Downgrade",
    "description": {
      "content": "The God of Sheep plays an RPG game recently. The game has a level system that records a player's level with a pair of positive integers A and B where A is the major level and B is the minor level. For",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10177K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The God of Sheep plays an RPG game recently. The game has a level system that records a player's level with a pair of positive integers A and B where A is the major level and B is the minor level. For...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ j \\in \\{1, \\dots, T\\} $:  \n- Let $ n, m, k \\in \\mathbb{Z} $ denote the number of problems, students, and ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments