当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5383:Yu-Gi-Oh!

题目描述
"Yu-Gi-Oh!", also known as "Dueling Monsters", is a popular trading card game which has nearly 20 years history. Next year, YGO will reach its 20th birthday.

Stilwell has $n$ monsters on the desk, each monster has its $level_i$ and $ATK_i$. There are two kinds of monsters, Tuner monsters and Non-Tuner monsters.

Now, Stilwell plans to finish some "Synchro Summon", and "Synchro Summon" is a kind of special summon following these rules (a little different from the standard YGO rules):

(1) A "Synchro Summon" needs two monsters as the material of this summon, and they must be one Tuner monster and one Non-Tuner monster.
In other words, we can cost one Tuner monster and one Non-Tuner monster to get a Synchro monster ("cost" means remove form the desk, "get" means put on to the desk).

(2) To simplify this problem, Synchro monsters are neither Tuner monsters nor Non-Tuner monsters.

(3) The level sum of two material must be equal to the level of Synchro monster we summon.
For example:
A Level 3 Tuner monster $+$ A Level 2 Non-Tuner monster $=$ A Level 5 Synchro Monster
A Level 2 Tuner monster $+$ A Level 4 Non-Tuner monster $=$ A Level 6 Synchro Monster
A Level 4 Tuner monster $+$ A Level 4 Non-Tuner monster $=$ A Level 8 Synchro Monster

(4) The material of some Synchro monster has some limits, the material must contain some specific monster.
For example:
A Level 5 Synchro Monster $\alpha$ requires A Level 3 Tuner monster $\alpha$ to be its material
A Level 6 Synchro Monster $\beta$ requires A Level 4 Non-Tuner monster $\beta$ to be its material
A Level 8 Synchro Monster $\gamma$ requires A Level 4 Tuner monster $\gamma$ $+$ A Level 4 Non-Tuner monster $\gamma$ to be its material
A Level 5 Synchro Monster $\varphi$ doesn't require any monsters to be its material
Then
A Level 3 Tuner monster $\alpha$ $+$ A Level 2 Non-Tuner monster $=$ A Level 5 Synchro Monster $\alpha$
A Level 3 Tuner monster $\delta$ $+$ A Level 2 Non-Tuner monster $\neq$ A Level 5 Synchro Monster $\alpha$
A Level 2 Tuner monster $+$ A Level 4 Non-Tuner monster $\beta$ $=$ A Level 6 Synchro Monster $\beta$
A Level 3 Tuner monster $+$ A Level 3 Non-Tuner monster $\zeta$ $\neq$ A Level 6 Synchro Monster $\beta$
A Level 4 Tuner monster $\gamma$ $+$ A Level 4 Non-Tuner monster $\gamma$ $=$ A Level 8 Synchro Monster $\gamma$
A Level 4 Tuner monster $\sigma$ $+$ A Level 4 Non-Tuner monster $\gamma$ $\neq$ A Level 8 Synchro Monster $\gamma$
A Level 4 Tuner monster $\gamma$ $+$ A Level 4 Non-Tuner monster $\phi$ $\neq$ A Level 8 Synchro Monster $\gamma$
A Level 3 Tuner monster $+$ A Level 2 Non-Tuner monster $=$ A Level 5 Synchro Monster $\varphi$
A Level 3 Tuner monster $\alpha$ $+$ A Level 2 Non-Tuner monster $=$ A Level 5 Synchro Monster $\varphi$

Stilwell has $m$ kinds of Synchro Monster cards, the quantity of each Synchro Monster cards is infinity.

Now, given $level_i$ and $ATK_i$ of every card on desk and every kind of Synchro Monster cards. Please finish some Synchro Summons (maybe zero) to maximum $\sum ATK_i$ of the cards on desk.
输入解释
The first line of the input contains a single number $T$, the number of test cases.

For each test case, the first line contains two integers $n$, $m$.

Next $n$ lines, each line contains three integers $tuner_i$, $level_i$, and $ATK_i$, describe a monster on the desk. If this monster is a Tuner monster, then $tuner_i=1$, else $tuner_i=0$ for Non-Tuner monster.

Next $m$ lines, each line contains integers $level_j$, $ATK_j$, $r_j$, and following $r_j$ integers are the required material of this Synchro Monster (the integers given are the identifier of the required material).
The input data guarantees that the required material list is available, two Tuner monsters or two Non-Tuner monsters won't be required. If $r_i=2$ the level sum of two required material will be equal to the level of Synchro Monster.

$T\leq 10$, $n,m\leq 300$, $1\leq level_i\leq 12$, $0\leq ATK_i\leq 5000$, $0\leq r_i\leq 2$
输出解释
$T$ lines, find the maximum $\sum ATK_i$ after some Synchro Summons.
输入样例
5
2 2
1 3 1300
0 2 900
5 2300 1 1
8 2500 0
2 1
1 3 1300
1 2 900
5 2300 1 1
3 1
1 3 1300
0 2 900
0 2 800
5 2300 1 1
3 1
1 1 233
0 1 233
0 1 200
2 466 2 1 2
6 3
1 3 1300
0 2 900
0 5 1350
1 4 1800
0 10 4000
0 10 1237
5 2300 1 1
8 3000 0
6 2800 0
输出样例
2300
2200
3200
666
11037
来自杭电HDUOJ的附加信息
Author SXYZ
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5383

最后修改于 2020-10-25T23:22:13+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/65536K(Java/Others)