#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
int validOrNot(int array[],int spotCount); // prototype of validOrNot function
int main(int argc, char** argv) {
int testCase,spotCount,ans;
int queueArray = (int)malloc(sizeof(int)*spotCount);
scanf("%d %d",&testCase,&spotCount);
for (int i = 0; i < testCase;i++) {
for(int j = 0; j < spotCount; j++) {
scanf("%d",&queueArray[j]);
}
// debugging portion
// printf(“Debugging the actuall array value: “);
// for(int itter = 0; itter <spotCount;itter++) printf(”%d\t”,queueArray[itter]);
// printf("\n");
// Debugging portion
ans = validOrNot(queueArray,spotCount); // Validating the array for yes or no
if (ans == 1) printf("Yes\n");
else printf("No\n");
scanf("%d",&spotCount);
}
return 0;
}
int validOrNot(int array,int spotCount) {
int count = 0,oneCount = 0;
/ printf("\nWorking for array : “);
for(int i =0 ; i < spotCount;i++) {
printf(”%d",array[i]);
}
printf("\n");*/
for (int i = 0; i < spotCount; i++) {
if (array[i] == 1) oneCount++;
else continue;
}
/* if (oneCount > 2) {
printf("\nThere are more than 2 one is exist!! Be carefull\n");
}*/
for (int i = 0; i < spotCount;i++) {
if (array[i] == 1) {
// count = 0;
++count;
} else if (oneCount > 2) {
count = 0;
++count;
}
else {
if(array[i+1] < 1) count++;
}
}
//printf("\nValue of count is : %d",count);
if(count >= 6) {
return 1;
} else if (count < 6) {
return -1;
}
}