CF241C.Mirror Box

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Mirror Box is a name of a popular game in the Iranian National Amusement Park (INAP). There is a wooden box, 105 cm long and 100 cm high in this game. Some parts of the box's ceiling and floor are covered by mirrors. There are two negligibly small holes in the opposite sides of the box at heights h__l and h__r centimeters above the floor. The picture below shows what the box looks like.

In the game, you will be given a laser gun to shoot once. The laser beam must enter from one hole and exit from the other one. Each mirror has a preset number v__i, which shows the number of points players gain if their laser beam hits that mirror. Also — to make things even funnier — the beam must not hit any mirror more than once.

Given the information about the box, your task is to find the maximum score a player may gain. Please note that the reflection obeys the law "the angle of incidence equals the angle of reflection".

“镜面盒”是伊朗国家游乐园(INAP)中一款广受欢迎的游戏。游戏中有一个木制盒子,长 105 cm105\ \text{cm},高 100 cm100\ \text{cm}。盒子的顶部(天花板)和底部(地面)部分区域覆盖有镜子。盒子两侧相对的面上各有一个可忽略尺寸的小孔,分别位于距地面 hlh_l 厘米和 hrh_r 厘米的高度处。下图展示了该盒子的外观:

在本游戏中,玩家将获得一支激光枪,仅允许发射一次激光。激光束必须从一个孔射入,并从另一个孔射出。每面镜子均预设一个数值 viv_i,表示若激光束击中该镜子,则玩家获得 viv_i 分。此外——为了让游戏更富趣味性——激光束不得多次击中同一面镜子。

给定关于该盒子的所有信息,你的任务是求出玩家可能获得的最高得分。请注意:反射遵循“入射角等于反射角”的光学定律。

输入格式

The first line of the input contains three space-separated integers h__l, h__r, n (0 < h__l, h__r < 100, 0 ≤ n ≤ 100) — the heights of the holes and the number of the mirrors.

Next n lines contain the descriptions of the mirrors. The i-th line contains space-separated v__i, c__i, a__i, b__i; the integer v__i (1 ≤ v__i ≤ 1000) is the score for the i-th mirror; the character c__i denotes i-th mirror's position — the mirror is on the ceiling if c__i equals "T" and on the floor if c__i equals "F"; integers a__i and b__i (0 ≤ a__i < b__i ≤ 105) represent the x-coordinates of the beginning and the end of the mirror.

No two mirrors will share a common point. Consider that the x coordinate increases in the direction from left to right, so the border with the hole at height h__l has the x coordinate equal to 0 and the border with the hole at height h__r has the x coordinate equal to 105.

输入的第一行包含三个用空格分隔的整数 hlh_l、hrh_r、nn(0<hl,hr<1000 < h_l, h_r < 100,0≤n≤1000 \leq n \leq 100)——分别表示左右两个洞口的高度以及镜子的数量。

接下来的 nn 行描述了每面镜子。第 ii 行包含四个用空格分隔的值:viv_i、cic_i、aia_i、bib_i;其中整数 viv_i(1≤vi≤10001 \leq v_i \leq 1000)表示第 ii 面镜子的得分;字符 cic_i 表示第 ii 面镜子的位置——若 cic_i 为 "T",则镜子位于天花板上;若 cic_i 为 "F",则镜子位于地板上;整数 aia_i 和 bib_i(0≤ai<bi≤1050 \leq a_i < b_i \leq 10^5)表示该镜子在 xx 轴上的起始与终止坐标。

任意两面镜子之间不存在公共点。规定 xx 坐标从左向右递增,因此高度为 hlh_l 的左侧洞口所在边界对应的 xx 坐标为 00,而高度为 hrh_r 的右侧洞口所在边界对应的 xx 坐标为 10510^5。

输出格式

The only line of output should contain a single integer — the maximum possible score a player could gain.

输出仅有一行,包含一个整数——玩家可能获得的最高分数。

输入输出样例

  • 输入#1

    50 50 7
    10 F 1 80000
    20 T 1 80000
    30 T 81000 82000
    40 T 83000 84000
    50 T 85000 86000
    60 T 87000 88000
    70 F 81000 89000

    输出#1

    100
  • 输入#2

    80 72 9
    15 T 8210 15679
    10 F 11940 22399
    50 T 30600 44789
    50 F 32090 36579
    5 F 45520 48519
    120 F 49250 55229
    8 F 59700 80609
    35 T 61940 64939
    2 T 92540 97769

    输出#2

    120

说明/提示

The second sample is depicted above. The red beam gets 10 + 50 + 5 + 35 + 8 + 2 = 110 points and the blue one gets 120.

The red beam on the picture given in the statement shows how the laser beam can go approximately, this is just illustration how the laser beam can gain score. So for the second sample there is no such beam that gain score 110.

第二个样例如上图所示。红色光束得分为 10+50+5+35+8+2=11010 + 50 + 5 + 35 + 8 + 2 = 110,蓝色光束得分为 120120。

题目陈述中所给图片中的红色光束仅大致示意激光束可能的行进路径,仅为说明激光束如何得分的示意图。因此,在第二个样例中,并不存在实际能获得 110110 分的光束。

输入解题思路,AI测评打分。不知道怎么写?

首页