QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 512 MB 총점: 100 해킹 가능 ✓

#11378. 排名预测

통계

你和你的队友刚刚结束了一场 ICPC 比赛。五小时的比赛耗尽了你们的精力,你的队友已经吃掉了你的午餐。现在,你只能靠在桌边看着排行榜。颁奖典礼尚未举行,因此排行榜仍处于封榜状态。这意味着你知道整场比赛中所有提交的时间以及你们队伍的通过情况;但对于其他队伍,你知道他们每次提交的时间,也知道在封榜前他们的提交是否通过,却不知道封榜后提交的结果。

当你查看排行榜时,你注意到了一支你非常关心的队伍。你知道他们在封榜前每次提交的时间和状态,以及他们在封榜后每次提交的时间。你想知道他们的排名是否会严格高于你们的队伍。为了确定他们的排名是否可能严格高于你们,你还想知道他们在封榜后至少需要解出多少道题目。

在 ICPC 比赛中,罚时根据以下规则计算。假设一支队伍解出了 $m$ 道题,编号为 $1$ 到 $m$。对于每一道已解出的题目 $i$,设该题第一次通过的提交时间为 $t_i$,在该题通过前提交的次数为 $c_i$。罚时 $p$ 的计算公式如下:

$$p = \sum_{i=1}^{m} t_i + 20 \cdot c_i$$

在本题中,不考虑编译错误等不计入罚时的特殊因素。

对于两支队伍 $A$ 和 $B$,当且仅当 $A$ 解出的题目数量多于 $B$,或者在解题数量相等的情况下 $A$ 的罚时少于 $B$ 时,称队伍 $A$ 的排名严格高于队伍 $B$。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。

对于每个测试用例,第一行包含三个整数 $n, a, b$ ($10 \le n \le 15, 1 \le a \le n, 0 \le b \le 10^5$),分别表示比赛共有 $n$ 道题,你们队伍在比赛结束时解出了 $a$ 道题,罚时为 $b$。

第二行包含一个整数 $s$ ($0 \le s \le 10^3$),表示你关心的那支队伍在常规比赛期间的提交次数。

接下来的 $s$ 行,每行包含一个整数和两个字符串 $t, p, v$ ($0 \le t < 300$)。这表示在第 $t$ 分钟,对题目 $p$ 进行了一次提交,结果为 $v$。保证提交按时间顺序给出,$p$ 是前 $n$ 个大写字母之一,$v \in \{\text{ac}, \text{rj}, \text{pd}\}$。$\text{ac}$ 表示该提交通过,$\text{rj}$ 表示该提交未通过,$\text{pd}$ 表示该提交处于封榜状态,未知是否通过。保证当 $t < 240$ 时,$v$ 不为 $\text{pd}$;当 $t \ge 240$ 时,$v$ 保证为 $\text{pd}$。

输出格式

对于每个测试用例,输出一行一个整数。如果该队伍的最终排名不可能严格高于你们的队伍,输出 $-1$;否则,输出他们在封榜后至少需要解出多少道题目,才能使他们的最终排名严格高于你们。

样例

输入 1

1
11 6 900
13
11 C ac
34 J ac
52 D rj
61 D ac
193 A rj
207 A rj
220 G ac
245 A pd
247 A pd
262 H pd
299 A pd
299 C pd
299 K pd

输出 1

2

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.