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

建议使用的浏览器:

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

3475:Street Lamp

题目描述
There are N parallel streets, each with M street lamps, every day when it's about to dawn, you'll have to turn all of them off, the problem is, the lamps are wired in a strange way and turning off one lamp could affect others lamps' on-off states! Some of the lamps of the same street are wired but some are not, so turning on or off may make the lamp direct connecting to it change state (from on to off and vice versa).

Given a state of the wirings and of the street lamps, find the minimum number of switch turn all the lamps off!
输入解释
The first line is T (T <= 50), the number of test cases.
For each case, the first line containing 2 integers: N, M (0 < N <= 100 and 0 < M <= 10). Then 2N - 1 lines followed, describing the lamps and the wires between them. Each line is a street with m lamps, 'o' represent a lit lamp while '*' represent a lamp that already be turned off, '|' and '-' represent a wire that connecting two neighboring lamps. And the '\' ,'/' indicates a wire sideling connecting. And 'X' indicates two wires sideling connecting. For more details, please read the hint for test case.
输出解释
For each case, output "Case d: x", where d is the case number counted from one, and x is an integer represents the minimum number of switch to turn all the lamps off! If no method to turn all the lamps off, please output “-1” instead of x.
输入样例
3
2 2
*-o
   
o-*
2 2
*-o
 \ 
o-*
2 3
o o o
 X X 
o o o
输出样例
Case 1: -1
Case 2: 2
Case 3: 2
提示
In the second test case, you can switch the light (0, 0) and (1, 1) to turn all the lights off.
In the third test case, you can switch the light (0, 1) and (1, 1) to turn all the lights off.
来自杭电HDUOJ的附加信息
Author rectaflex
Recommend zhengfeng

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3475

最后修改于 2020-10-25T23:03:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/32768K(Java/Others)