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

建议使用的浏览器:

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

7140:Backpack

题目描述
Alice has a backpack of capacity $m$ that she now wants to fill with some items!

Alice has $n$ items, each of which has a volume $v_i$ and a value $w_i$.

Can a number of items be selected from n items such that the backpack is exactly full (ie the sum of the volumes equals the backpack capacity)? If so, what is the maximum XOR sum of the values of the items in the backpack when the backpack is full?
输入解释
The first line contains an integer $T(T \le 10)$ —the number of test cases.

The first line of each test case contains 2 integers $n,m(1 \le n,m < 2^{10})$ —the number of items, the capacity of the backpack.

The next $n$ lines , each line contains 2 integers $v_i,w_i(1 \le v_i,w_i < 2^{10})$ — the volume and value of the item.
输出解释
For each test case, output a single line, if the backpack cannot be filled, just output a line of "-1", otherwise output the largest XOR sum.
输入样例
1
5 4
2 4
1 6
2 2
2 12
1 14
输出样例
14

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

源链接: HDU-7140

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

共提交 0

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