| 11 | #include <stdio.h> |
| 12 | |
| 13 | int main(void) |
| 14 | { |
| 15 | int test; |
| 16 | scanf("%d",&test); |
| 17 | while(test) |
| 18 | { |
| 19 | test--; |
| 20 | int a[100]; //initializing an array to signify the queue |
| 21 | int i=1; //iterating variable for array starts from 1 as spots are labelled 1 to N |
| 22 | int spots=0; //variable to signify how many places are there to stand |
| 23 | int occ=0; //flag variable to signify if that atleast one spot is occupied (check constraints) |
| 24 | int j=0; //iterating variable to next 6 spots from the chosen spot |
| 25 | int flag=0; //flag variable to signify whether condition is met or not |
| 26 | scanf("%d",&spots); |
| 27 | for(i=1;i<=spots;i++) |
| 28 | { |
| 29 | scanf("%d",&a[i]); |
| 30 | if(a[i]==1) //explicitly checking constraints(not necessary) |
| 31 | occ=1; |
| 32 | if(a[i]>1||a[i]<0) //explicitly checking constraints(not necessary) |
| 33 | return; |
| 34 | } |
| 35 | if(occ==0) |
| 36 | return; |
| 37 | for(i=1;i<=spots;i++) //selecting each spot in the queue one by one |
| 38 | { |
| 39 | if(a[i]==1) //if the spot is filled then only proceed |
| 40 | { |
| 41 | for(j=i+1;j<i+6&&j<=spots;j++) //check if the next 6 spots are empty or not |
| 42 | { |
| 43 | if(a[j]==1) |
| 44 | flag=1; //found a filled spot prematurely |
| 45 | |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | if(flag==1) //if filled spot was found prematurely |
| 50 | printf("NO\n"); |
| 51 | |
| 52 | if(flag==0) //if people in queue follow protocol |
| 53 | printf("YES\n"); |
| 54 | } |
| 55 | return 0; |
| 56 | } |
| 57 |
nothing calls this directly
no outgoing calls
no test coverage detected