编程介的小学生 2019-03-26 22:19 采纳率: 20.5%
浏览 185

电灯和开关的一个变化判断问题,怎么才能使用C程序的语言设计来编写程序代码

Problem Description
There are N lamps in a line and M switches control them. Each switch is connected to a subset of these lamps. When a switch is flipped, all the lamps connected to it change its state (on to off and off to on).

Input
The input contains multiple test cases. Each test case starts with two integers N and M (0<N<=50, 0<M<=100), which stand for the number of lamps and swithes. Then M lines follows, each line contains N characters. The jth character of the ith line is '1' if the ith switch is connected to the jth lamp, and '0' otherwise. The next line is a integer Q, which is the number of queries. Each of following Q lines contains the initial and target state of lamps ('0' is off and '1' is on).

Output
For each query, output "Yes" if it is possible to change the state from initial to target with these swithes. Otherwise, output "No".

Sample Input
5 3
00000
10101
01010
3
00000 11111
10101 01010
11111 10001

Sample Output
Yes
Yes
No

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择
    • ¥15 这款软件是什么?需要能满足我的需求
    • ¥15 SpringSecurityOauth2登陆前后request不一致