CF1184B2.The Doctor Meets Vader (Medium)

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Thanks to the Doctor's help, the rebels managed to steal enough gold to launch a full-scale attack on the Empire! However, Darth Vader is looking for revenge and wants to take back his gold.

The rebels have hidden the gold in various bases throughout the galaxy. Darth Vader and the Empire are looking to send out their spaceships to attack these bases.

The galaxy can be represented as an undirected graph with nn planets (nodes) and mm wormholes (edges), each connecting two planets.

A total of ss empire spaceships and bb rebel bases are located at different planets in the galaxy.

Each spaceship is given a location xx, denoting the index of the planet on which it is located, an attacking strength aa, and a certain amount of fuel ff.

Each base is given a location xx, and a defensive strength dd.

A spaceship can attack a base if both of these conditions hold:

  • the spaceship's attacking strength is greater or equal than the defensive strength of the base
  • the spaceship's fuel is greater or equal to the shortest distance, computed as the number of wormholes, between the spaceship's planet and the base's planet

Vader is very particular about his attacking formations. He requires that each spaceship is to attack at most one base and that each base is to be attacked by at most one spaceship.

Vader knows that the rebels have hidden kk gold in each base, so he will assign the spaceships to attack bases in such a way that maximizes the number of bases attacked.

Therefore, for each base that is attacked, the rebels lose kk gold.

However, the rebels have the ability to create any number of dummy bases. With the Doctor's help, these bases would exist beyond space and time, so all spaceship can reach them and attack them. Moreover, a dummy base is designed to seem irresistible: that is, it will always be attacked by some spaceship.

Of course, dummy bases do not contain any gold, but creating such a dummy base costs hh gold.

What is the minimum gold the rebels can lose if they create an optimal number of dummy bases?

在博士的帮助下,反抗军成功窃取了足够多的黄金,得以对银河帝国发动全面进攻!然而,达斯·维达渴望复仇,想要夺回属于他的黄金。

反抗军已将黄金藏匿于银河系各处的多个基地中。达斯·维达与帝国正计划派出宇宙飞船攻击这些基地。

整个银河系可建模为一个无向图,包含 nn 颗行星(节点)和 mm 个虫洞(边),每条边连接两颗行星。

共有 ss 艘帝国飞船和 bb 座反抗军基地,分别位于银河系中不同的行星上。

每艘飞船具有以下属性:位置 xx(表示其所在行星的编号)、攻击力 aa、以及燃料量 ff。

每座基地具有以下属性:位置 xx(表示其所在行星的编号)、防御力 dd。

一艘飞船能够攻击一座基地,当且仅当同时满足以下两个条件:

  • 该飞船的攻击力不小于该基地的防御力;
  • 该飞船的燃料量不小于该飞船所在行星与该基地所在行星之间的最短距离(以虫洞数量计)。

维达对进攻阵型极为讲究:他要求每艘飞船最多攻击一座基地,且每座基地最多被一艘飞船攻击。

维达知道反抗军在每座基地中藏匿了 kk 单位黄金,因此他将指派飞船攻击基地,以最大化被攻击的基地数量。

于是,每座被攻击的基地,反抗军都将损失 kk 单位黄金。

然而,反抗军有能力建造任意数量的诱饵基地(dummy bases)。在博士的帮助下,这些诱饵基地存在于时空之外,因此所有飞船均可抵达并攻击它们。此外,诱饵基地被设计得极具吸引力:即总会被某艘飞船攻击。

当然,诱饵基地中不含任何黄金,但每建造一座诱饵基地需耗费 hh 单位黄金。

若反抗军建造最优数量的诱饵基地,他们所能承受的最小黄金损失是多少?

输入格式

The first line contains two integers nn and mm (1≤n≤1001 \leq n \leq 100, 0≤m≤100000 \leq m \leq 10000), the number of nodes and the number of edges, respectively.

The next mm lines contain two integers uu and vv (1≤u1 \leq u, v≤nv \leq n) denoting an undirected edge between the two nodes.

The next line contains four integers ss, bb, kk and hh (1≤s1 \leq s, b≤1000b \leq 1000, 0≤k0 \leq k, h≤109h \leq 10^9), the number of spaceships, the number of bases, the cost of having a base attacked, and the cost of creating a dummy base, respectively.

The next ss lines contain three integers xx, aa, ff (1≤x≤n1 \leq x \leq n, 0≤a0 \leq a, f≤109f \leq 10^9), denoting the location, attack, and fuel of the spaceship.

The next bb lines contain two integers xx, dd (1≤x≤n1 \leq x \leq n, 0≤d≤1090 \leq d \leq 10^9), denoting the location and defence of the base.

第一行包含两个整数 nn 和 mm(1≤n≤1001 \leq n \leq 100,0≤m≤100000 \leq m \leq 10000),分别表示节点数和边数。

接下来的 mm 行每行包含两个整数 uu 和 vv(1≤u,v≤n1 \leq u, v \leq n),表示节点 uu 与节点 vv 之间存在一条无向边。

下一行包含四个整数 ss、bb、kk 和 hh(1≤s,b≤10001 \leq s, b \leq 1000,0≤k,h≤1090 \leq k, h \leq 10^9),分别表示飞船数量、基地数量、基地被攻击时的代价,以及建造一个虚假基地的代价。

接下来的 ss 行每行包含三个整数 xx、aa、ff(1≤x≤n1 \leq x \leq n,0≤a,f≤1090 \leq a, f \leq 10^9),分别表示该飞船的位置、攻击力和燃料量。

接下来的 bb 行每行包含两个整数 xx、dd(1≤x≤n1 \leq x \leq n,0≤d≤1090 \leq d \leq 10^9),分别表示该基地的位置和防御力。

输出格式

Print a single integer, the minimum cost in terms of gold.

输出一个整数,即以金币为单位的最小花费。

输入输出样例

  • 输入#1

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

    输出#1

    12

说明/提示

One way to minimize the cost is to build 44 dummy bases, for a total cost of 4×3=124 \times 3 = 12.

One empire spaceship will be assigned to attack each of these dummy bases, resulting in zero actual bases attacked.

最小化成本的一种方法是建造 44 个虚拟基地,总成本为 4×3=124 \times 3 = 12。

每个虚拟基地将分配一艘帝国飞船进行攻击,因此实际被攻击的基地数量为零。

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

首页