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

建议使用的浏览器:

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

1903:Jurassic Remains

Special Judge 特殊评判
题目描述
Paleontologists in Siberia have recently found a number of fragments of Jurassic period dinosaur skeleton. The paleontologists have decided to forward them to the paleontology museum. Unfortunately, the dinosaur was so huge, that there was no box that the fragments would fit into. Therefore it was decided to split the skeleton fragments into separate bones and forward them to the museum where they would be reassembled. To make reassembling easier, the joints where the bones were detached from each other were marked with special labels. Meanwhile, after packing the fragments, the new bones were found and it was decided to send them together with the main fragments. So the new bones were added to the package and it was sent to the museum.

However, when the package arrived to the museum some problems have shown up. First of all, not all labels marking the joints were distinct. That is, labels with letters 'A' to 'Z' were used, and each two joints that had to be connected were marked with the same letter, but there could be several pairs of joints marked with the same letter.

Moreover, the same type of labels was used to make some marks on the new bones added to the box. Therefore, there could be bones with marked joints that need not be connected to the other bones. The problem is slightly alleviated by the fact that each bone has at most one joint marked with some particular letter.

Your task is to help the museum workers to restore some possible dinosaur skeleton fragments. That is, you have to find such set of bones, that they can be connected to each other, so that the following conditions are true:
If some joint is connected to the other joint, they are marked with the same label.
  • For each bone from the set each joint marked with some label is connected to some other joint.
  • The number of bones used is maximal possible.

Note that two bones may be connected using several joints.
输入解释
The first line of the input contains N -- the number of bones (1 <= N <= 24). Next N lines contain bones descriptions: each line contains a non-empty sequence of di#erent capital letters, representing labels marking the joints of the corresponding bone.
输出解释
On the first line of output print L -- the maximal possible number of bones that could be used to reassemble skeleton fragments. Then print on the next line L integer numbers in ascending order -- the bones to be used. Bones are numbered starting from one, as they are given in the input.
输入样例
6
ABD
EG
GE
ABE
AC
BCD
输出样例
5
1 2 3 5 6

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

源链接: POJ-1903

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

共提交 0

通过率 --%
时间上限 内存上限
10000 30000