CF1874G.Jellyfish and Inscryption

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

Jellyfish loves playing a game called "Inscryption" which is played on a directed acyclic graph with nn vertices and mm edges. All edges a→ba \to b satisfy a<ba \lt b.

You need to move from vertex 11 to vertex nn along the directed edges, and then fight with the final boss.

You will collect cards and props in the process.

Each card has two attributes: HP and damage. If a card's HP is aa and its damage is bb, then the power of the card is a×ba \times b.

Each prop has only one attribute: power.

In addition to vertex 11 and vertex nn, there are some vertices that trigger special events. The special events are:

  1. You will get a card with aa HP, and bb damage.
  2. If you have at least one card, choose one of your cards and increase its HP by xx.
  3. If you have at least one card, choose one of your cards and increase its damage by yy.
  4. You will get a prop with ww power.

When you get to vertex nn, you can choose at most one of your cards and multiply its damage by 10910^9.

The final boss is very strong, so you want to maximize the sum of the power of all your cards and props. Find the maximum possible sum of power of all your cards and props if you play the game optimally.

水母很喜欢玩一款名为“Inscryption”的游戏,该游戏在一个包含 nn 个顶点和 mm 条边的有向无环图上进行。所有边 a→ba \to b 均满足 a<ba \lt b。

你需要沿着有向边从顶点 11 移动到顶点 nn,然后与最终 Boss 战斗。

在此过程中,你将收集卡牌和道具。

每张卡牌有两个属性:生命值(HP)和攻击力(damage)。若某张卡牌的 HP 为 aa、攻击力为 bb,则该卡牌的强度(power)为 a×ba \times b。

每个道具只有一个属性:强度(power)。

除顶点 11 和顶点 nn 外,图中还存在若干触发特殊事件的顶点。这些特殊事件包括:

  1. 获得一张 HP 为 aa、攻击力为 bb 的卡牌;
  2. 若你至少拥有一张卡牌,则可选择其中一张,将其 HP 增加 xx;
  3. 若你至少拥有一张卡牌,则可选择其中一张,将其攻击力增加 yy;
  4. 获得一个强度为 ww 的道具。

当你抵达顶点 nn 时,你可以至多选择一张你所拥有的卡牌,并将其攻击力乘以 10910^9。

最终 Boss 非常强大,因此你希望最大化你所拥有全部卡牌与道具的强度总和。若你以最优策略进行游戏,求此强度总和的最大可能值。

输入格式

The first line contains two integers nn and mm (2≤n≤2002 \leq n \leq 200, n−1≤m≤min⁡(n(n−1)2,2000)n - 1\leq m \leq \min(\frac{n(n-1)}2, 2000)) — the number of the vertices and the number of the edges.

In the following nn lines, the ii-th (1≤i≤n)(1 \leq i \leq n) line describes the special event that will trigger on vertex ii:

  • 0 — no special events.
  • 1 a b (1≤a,b≤2001 \leq a, b \leq 200) — you will get a card with aa HP, and bb damage.
  • 2 x (1≤x≤2001 \leq x \leq 200) — if you have at least one card, choose one of your cards and increase its HP by xx.
  • 3 y (1≤y≤2001 \leq y \leq 200) — if you have at least one card, choose one of your cards and increase its damage by yy.
  • 4 w (1≤w≤1061 \leq w \leq 10^6) — you will get a prop with ww power.

In the following mm lines, each line contains two integers uu and vv (1≤u<v≤n1 \leq u \lt v \leq n) representing a directed edge from vertex uu to vertex vv.

It is guaranteed that every edge (u,v)(u,v) appears at most once.

It is guaranteed that there are no special events on vertex 11 and vertex nn.

It is guaranteed that for all ii, there exists a path from vertex 11 to vertex nn that passes through vertex ii.

第一行包含两个整数 nn 和 mm(2≤n≤2002 \leq n \leq 200,n−1≤m≤min⁡(n(n−1)2,2000)n - 1\leq m \leq \min(\frac{n(n-1)}2, 2000)),分别表示顶点数和边数。

接下来的 nn 行中,第 ii 行(1≤i≤n1 \leq i \leq n)描述在顶点 ii 上触发的特殊事件:

  • 0 — 无特殊事件。
  • 1 a b(1≤a,b≤2001 \leq a, b \leq 200)— 获得一张具有 aa 点生命值(HP)和 bb 点攻击力(damage)的卡牌。
  • 2 x(1≤x≤2001 \leq x \leq 200)— 若你至少拥有一张卡牌,则任选其中一张,将其生命值增加 xx。
  • 3 y(1≤y≤2001 \leq y \leq 200)— 若你至少拥有一张卡牌,则任选其中一张,将其攻击力增加 yy。
  • 4 w(1≤w≤1061 \leq w \leq 10^6)— 获得一件具有 ww 点力量(power)的道具。

接下来的 mm 行中,每行包含两个整数 uu 和 vv(1≤u<v≤n1 \leq u \lt v \leq n),表示一条从顶点 uu 指向顶点 vv 的有向边。

保证每条边 (u,v)(u,v) 至多出现一次。

保证顶点 11 和顶点 nn 上均无特殊事件。

保证对任意 ii,均存在一条从顶点 11 到顶点 nn 的路径,且该路径经过顶点 ii。

输出格式

Output a single integer — the maximum sum of the power of all your cards and props.

输出一个整数——你所有卡片和道具的力量值之和的最大值。

输入输出样例

  • 输入#1

    6 8
    0
    1 2 10
    1 6 6
    2 8
    3 10
    0
    1 2
    1 3
    2 4
    2 5
    3 4
    3 5
    4 6
    5 6

    输出#1

    100000000000
  • 输入#2

    4 3
    0
    4 1000000
    4 1000000
    0
    1 2
    2 3
    3 4

    输出#2

    2000000
  • 输入#3

    16 15
    0
    1 1 10
    1 10 1
    2 4
    3 4
    1 20 20
    2 30
    3 20
    1 1 100
    2 9
    1 1 200
    2 9
    3 10
    1 190 100
    2 10
    0
    1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    7 8
    8 9
    9 10
    10 11
    11 12
    12 13
    13 14
    14 15
    15 16

    输出#3

    20000000005600
  • 输入#4

    9 9
    0
    1 1 200
    3 200
    3 200
    3 200
    3 200
    1 200 200
    3 200
    0
    1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    7 8
    8 9
    1 9

    输出#4

    80000000001000
  • 输入#5

    9 8
    0
    1 20 200
    3 200
    3 200
    2 5
    1 100 200
    3 200
    3 200
    0
    1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    7 8
    8 9

    输出#5

    60000000015000
  • 输入#6

    16 34
    0
    0
    0
    2 6
    3 1
    4 27
    4 40
    3 9
    0
    2 6
    1 8 1
    0
    2 2
    1 10 7
    2 9
    0
    2 4
    3 10
    2 11
    2 7
    13 15
    3 15
    2 3
    6 14
    4 12
    10 12
    9 10
    7 8
    4 13
    11 12
    4 6
    11 16
    14 15
    2 5
    5 15
    9 13
    8 14
    1 3
    2 15
    12 16
    7 10
    4 5
    1 2
    4 11
    4 9
    4 16
    3 6
    6 8
    7 11
    15 16

    输出#6

    133000000040

说明/提示

In the first example, we will play the game in the following order:

  • move from vertex 11 to vertex 22, get a card with 22 HP, and 1010 damage.
  • move from vertex 22 to vertex 44, choose the card we get from vertex 22 and increase its HP by 88.
  • move from vertex 44 to vertex 66, choose the card we get from vertex 22 and multiply its damage by 10910^9.

In the end, we will have a card with (2+8)=10(2+8)=10 HP and 10×109=101010 \times 10^9=10^{10} damage, It's power is 10×1010=101110 \times 10^{10}=10^{11}. Because we only have the card we get from vertex 22, so the sum of power of all your cards and props is 101110^{11}.

在第一个例子中,我们将按以下顺序进行游戏:

  • 从顶点 11 移动到顶点 22,获得一张具有 22 点生命值(HP)和 1010 点伤害的卡牌。
  • 从顶点 22 移动到顶点 44,选择在顶点 22 获得的卡牌,并将其生命值(HP)增加 88。
  • 从顶点 44 移动到顶点 66,选择在顶点 22 获得的卡牌,并将其伤害乘以 10910^9。

最终,我们将拥有一张生命值为 (2+8)=10(2+8)=10、伤害为 10×109=101010 \times 10^9=10^{10} 的卡牌,其力量值为 10×1010=101110 \times 10^{10}=10^{11}。由于我们仅拥有在顶点 22 获得的这张卡牌,因此所有卡牌与道具的力量值总和为 101110^{11}。

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

首页