Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓
统计

你正在玩 RunEscape。Slayer 是一项活动,你需要反复完成形式为“击杀 $x$ 只 $y$ 类型的怪物”的任务。你正在思考训练 Slayer 的最快方法。

共有 $n$ 位 Slayer 大师可以为你提供任务。第 $i$ 位 Slayer 大师有 $m_i$ 个任务可以分配给你。你已知每个任务的以下信息: $f_{ij}$ — 任务的频率; $t_{ij}$ — 完成任务所需的分钟数; * $e_{ij}$ — 执行任务时每分钟获得的 XP。

当你完成一个任务时,你会获得 $c$ 点 Slayer 积分。当你接到一个任务时,你可以花费 $s$ 点 Slayer 积分来跳过它。你按以下步骤循环操作:

  1. 选择一位 Slayer 大师。设 $i$ 为所选大师的索引。
  2. 屏蔽最多 $b$ 个他们的任务,并至少保留一个不被屏蔽。设 $B$ 为你屏蔽的任务索引集合。接收第 $j$ 个任务的概率变为: $$P(j) = \begin{cases} \frac{f_{ij}}{\sum_{k \notin B} f_{ik}} & \text{如果 } j \notin B \\ 0 & \text{如果 } j \in B \end{cases}$$
  3. Slayer 大师使用 $P$ 随机分配给你一个任务。你可以选择跳过该任务并损失 $s$ 点积分,或者完成它并获得 $c$ 点积分。
  4. 回到第 1 步。

你从 0 点 Slayer 积分开始。计算 $e$,即在保证 Slayer 积分永远不低于 0 的前提下,假设你做出最优选择时,每分钟所能获得的最大期望 XP。参见下文的“说明”部分以获取 $e$ 的正式定义。

输入格式

第一行包含三个整数 $b$ ($0 \le b \le 3 \cdot 10^4$),$c$ 和 $s$ ($1 \le c, s \le 10^4$)。 第二行包含一个整数 $n$ ($1 \le n \le 10^3$) — Slayer 大师的数量。接下来是他们任务的描述。 每位 Slayer 大师的第一行包含一个整数 $m_i$ ($1 \le m_i \le 3 \cdot 10^4$) — 该大师拥有的任务数量。 接下来的 $m_i$ 行包含三个整数 $f_{ij}, t_{ij}$ 和 $e_{ij}$ ($1 \le f_{ij}, t_{ij}, e_{ij} \le 10^4$)。 保证所有 $m_i$ 之和不超过 $3 \cdot 10^4$。

输出格式

输出一个浮点数:$e$。 如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。形式上,设你的答案为 $a$,标准答案为 $b$,当且仅当满足以下条件时你的答案被接受: $$\frac{|a - b|}{\max(1, |b|)} \le 10^{-6}$$

样例

样例输入 1

0 1 6
2
1
1 1 1
2
1 10 1
1 10 10

样例输出 1

7.000000000000

样例输入 2

2 1 2
1
4
10 2 1
10 1 1
1 10 1
1 1 10

样例输出 2

5.909090909091

说明

我们现在正式定义 $e$。 设 $q$ 为自然数。考虑进行恰好 $q$ 次循环。一个策略是一个由 $q$ 个元组 $(i_k, B_k, t_k)$ 组成的序列。其中第 $k$ 个元组描述了你在第 $k$ 次迭代中的操作: $i_k$ 是你在第 $k$ 步选择的 Slayer 大师的索引。 $B_k$ 是你在第 $k$ 步屏蔽的任务集合。 * $t_k$ 是一个函数 $\mathbb{N}_0 \to 2^{\{1, 2, \dots, m_{i_k}\}}$。$t_k(p)$ 描述了当你拥有恰好 $p$ 点 Slayer 积分时,你将跳过的任务集合。如果 $p < s$,则 $t_k(p) = \emptyset$。

对于每个策略,其效率定义为获得的 XP 期望值除以所需时间的期望值。设 $e_q$ 为所有策略中的最大效率。 那么 $$e = \lim_{q \to \infty} e_q$$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#103EditorialOpen题解Kevin53072025-12-12 19:46:24View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.