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

建议使用的浏览器:

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

7181:Fight and upgrade

题目描述
You lead an army to fight monsters in a world where the blood of monsters is composed of physical blood $hp_p$ and magical blood $hp_m$.

Your army has $n$ soldiers, the $i$-th soldier has $k_i$ attack methods, and the $j$-th attack method of the $i$th soldier causes $p_{ij}$ points of physical damage and $m_{ij}$ points of magic damage to the monster.

The total attack power of an army is the sum of the attack power of each soldier, and the attack power of each soldier is a weakly normalized linear combination of all attack methods of this soldier, i.e., the coefficients sum of the linear combination is less than or equal to 1. Formally, if the physical damage caused by a total attack of the army is $hurt_p$ and the magic damage is $hurt_m$, then

$$hurt_p = \sum\limits_{i=1}^{n}{\sum\limits_{j=1}^{k_i}{c_{ij}*p_{ij}}}$$


$$hurt_m = \sum\limits_{i=1}^{n}{\sum\limits_{j=1}^{k_i}{c_{ij}*m_{ij}}}$$

where $c_{ij}$ is the weight assigned by the $i$-th soldier to the $j$-th attack, satisfying: $\forall i:\sum\limits_{j=1}^{k_i} {c_{ij}} \leq 1$, $\forall c_{ij} \geq 0$.

Since you're competitive, you want to know if you can kill the monster in just $1$ attack. After your army fights the $r$-th monster, whether or not it can be killed by your army in a single attack, it will drop an attack method that will be gained by the $s_r$-th soldier.

During the expedition, you will encounter $q$ monsters in turn. For the $r$-th monster, it has five attributes $hp_{pr},hp_{mr},p_r,m_r,s_r$, which indicate the physical blood, magic blood, the physical damage and magic damage of the new attack method, the number of the soldier who gained the attack method after the battle.

To defeat a monster, you need to find an attack combination that makes the monster's physical and magic HP exactly 0.
输入解释
The input consists of multiple test cases.

The first line contains an integer $T$ ($T=11$) -- the number of test cases.

For each test case:

The first line contains two positive integers $n,q$($1 \leq n\leq 10^3, 1\leq q\leq 10^5$), which indicates the number of soldiers and the total number of monsters.

The next $3*n$ rows describe the attacks of $n$ soldiers. The $3\*i-2$ to $3\*i$ rows describe the original attack of the $i$-th soldier: first an integer $k_i$($1\leq k_i \leq 10^5$) indicating the number of attack methods of this soldier; the next $k_i$ non-negative integer $p_{ij}$($0 \leq p_{ij} \leq 10^6$) indicating the physical damage of the $j$ attack of the $i$ soldier; the next $k_i$ non-negative integer $m_{ij}$($0 \leq m_{ij} \leq 10^6$) indicating the magic damage of the $j$ attack of the $i$ soldier.

The next $q$ rows, each containing five integers $hp_{pr},hp_{mr},p_r,m_r,s_r$($0\leq hp_p,hp_m\leq 10^9, 1\leq s_r \leq n, 0 \leq p_r,m_r \leq 10^6$,), indicate the $physical$ $blood$, $magic$ $blood$ of the $r$-th monster, the $physical$ $damage$ of the new attack and the $magic$ $damage$ of the new attack, the $soldier$ $number$ that gained this attack method.

For a single test case, it is guaranteed that $\sum\limits_{i=1}^{n} k_i \leq 10^5$.

$Note:$ Not all 11 test cases are full, just make sure your time complexity can run a test case in 3s.
输出解释
For each test case, output $q$ rows containing $YES$ or $NO$, indicating whether the monster can be defeated in $1$ attack.
输入样例
2
2 3
1
1
0
1
1
0
1 1 0 1 1
1 1 0 1 2
0 2 1 1 1
2 2
3
13 11 4
11 0 9
3
4 16 4
4 16 11
20 26 15 19 2
20 26 1 1 1
输出样例
NO
YES
YES
NO
YES

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

源链接: HDU-7181

最后修改于 2022-09-15T06:17:12+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/8000MS(Java/Others) 131072/131072K(Java/Others)