Ambikapathy wants to decorate his girlfriend Amaravathi's house with a series of lights. The number of lights is M. Initially, all the lights are switched off. Ambikapathy finds that there are K numbers of buttons, each of them is connected to a set of lights. Ambikapathy can press any of these buttons. When the button is pressed, it turns on all the lights it’s connected to. Can Ambikapathy accomplish his task to switch on all the lights? If Ambikapathy presses the button such that some lights connected to it are already turned on, they do not change their state, i.e. remain turned on. Help him in his task to impress his valentine.
#include <stdio.h>
int main()
{ int k,m,count=0;
scanf("%d %d",&k,&m);
while(k--) {
int lights[m];
int i;
for(i=0;i<m;i++) {
scanf("%d",&lights[i]);
}
for(i=0;i<m;i++){
if(lights[i]<=m);
else{
count+=1;
}
}
}
if(count==0){
printf("YES");
}
else{
printf("NO");
}
return 0;
}
Comments
Post a Comment