8476: Backpack

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

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 ≤ 10) —the number of test cases.
The first line of each test case contains 2 integers n,m(1 ≤ 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 ≤ 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 1otherwise
output the largest XOR sum.

输入样例 复制

1
5 4
2 4
1 6
2 2
2 12
1 14

输出样例 复制

14

分类标签