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

建议使用的浏览器:

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

2133:Cow Imposters

题目描述
FJ no longer uses the barbaric custom of branding to mark the cows that he owns. Instead, he creates a binary code of B (1 <= B <= 16) bits for each cow and embosses it onto a metal strip that is fastened to each cow's ear.

The cows have taken in a stray and wish to create an ID strip for it. Unknown to FJ, they have created a machine that can make a new ID strip by combining two existing ID strips using the XOR operation (ID strips are not consumed by this machine, and the same ID strip can be used for both inputs).

The cows wish to create a specific ID strip for the stray or at least get as close to a desired ID as possible -- with the smallest possible number of bits differing between the goal ID strip and the best possible new ID strip.

Given a set of E (1 <= E <= 100) existing ID strips, the goal ID strip, and a large number of blank ID strips to hold intermediate results, calculate the closest possible ID strip that can be created from the existing ID strips.

If more than one ID is closest, choose the one that can be created in the fewest steps. If there is still a tie, choose the `smallest' ID (i.e., if you sorted all the IDs, the one that is first).
输入解释
* Line 1: Two space-separated integers: B and E.

* Line 2: The goal ID string, represented as a string of B 0's and 1's (with no spaces).

* Lines 3..E+2: Each line contains an existing ID string, represented as a string of B 0's and 1's (with no spaces).

输出解释
* Line 1: A single integer that is the minimum number of steps required to create the best possible ID strip.

* Line 2: A single line with the best possible ID strip that can be created from the E existing ID strips
输入样例
5 3
11100
10000
01000
00100
输出样例
2
11100

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2133

最后修改于 2020-10-29T06:24:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536