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

建议使用的浏览器:

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

3884:Gearbox

题目描述
Jake decided to take the gearbox of his car apart and put it back together for 'learning purposes'. A gearbox is a box containing many gears, cogs and sprockets (as well as several springs and pinions). All these parts are connected together in intricate ways. Consequently, he is not completely sure if every part is in the correct position again.
All gears are placed on metal rods; when one gear on a rod turns, they all turn by an equal angle. The rods are connected by springs and plastic bars, but Jake is pretty sure he has that part right. The cogs and sprockets are not connected to anything, they are free to rattle around in the box. This may be a bit strange, but a quick Google search reveals that this is customary for gearboxes of this type.
The only problem is that some gears are interlocked, which could cause the main drive shaft to jam. The gearbox uses modern InfiniTeethTM gears, which means that it is impossible to count the number of teeth on a gear. All gears have a type number, and gears of the same type have the same number of teeth. According to the manual (which Jake should have read before he started this mess) all rods should be able to turn, regardless of the number of teeth on each type of gear. So Jake concludes that if this is true for his gearbox it is definitely assembled correctly.

输入解释
On the first line of the input is a positive integer, the number of test cases. Then for each test case:
A line with three integers ng, nr and ni (all < 105), the number of gears, rods and interlockings.
ng lines, each containing two integers 0 < ti < 100 and 0 <= ri < nr, the type number of gear i and the index of the rod it is on respectively.
ni lines, each containing two integers 0 <= aj < bj < ng, indicating that gears aj and bj are interlocked.
输出解释
For each test case:
One line containing the text "ok" if the gearbox is de nitely assembled correctly, and "jammed" otherwise.
输入样例
4
2 2 1
1 0
2 1
0 1
8 4 4
20 0
10 1
20 2
10 3
30 0
30 1
40 2
40 3
0 1
2 3
4 6
5 7
8 4 4
20 0
10 1
20 2
10 3
30 0
40 1
40 2
30 3
0 1
2 3
4 6
5 7
3 3 3
1 0
1 1
1 2
0 1
0 2
1 2
输出样例
ok
ok
jammed
jammed

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

题目来源 BAPC 2009

源链接: POJ-3884

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

共提交 0

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