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

建议使用的浏览器:

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

3408:The Domino Principle

题目描述

There is a configuration of N domino stones that is to be beautifully destroyed. For each stone i in the given configuration, we know the set Di of the stones that will fall at time t+1 (if they have not fallen before) if the stone i falls at time t.

Write a program to determine which stone should be pushed to fall at the time 0 to achieve complete destruction of the configuration that takes the longest possible time.

输入解释

The first line of the input contains the number of stones N in the configuration (1≤N≤1000). Next N lines describe sets Di (1≤iN). Each of these lines contains first the potency of the set Di and then the numbers of stones in the set separated by one or more spaces.

输出解释

The first line of the output must contain the time of fall of the last stone in the configuration, and the second line - the number of the stone that should be pushed first. If the maximal time can be achieved starting from several initial stones, output the maximal possible number. If the configuration can’t be destroyed completely, the first and only line of the file must contain the word ‘impossible’.

输入样例
3
2 2 3
1 3
0
输出样例
1
1

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

源链接: POJ-3408

最后修改于 2020-10-29T07:00:53+00:00 由爬虫自动更新

共提交 0

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