编程介的小学生 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 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序