#K39322. Safe Drawbridge

    ID: 26395 Type: Default 1000ms 256MiB

Safe Drawbridge

Safe Drawbridge

You are given a set of test cases. For each test case, you are given an integer \(N\) representing the number of segments in a drawbridge and a sequence of \(N\) integers. Each integer in the sequence is either 0 or 1, where:

  • \(0\) indicates a safe segment.
  • \(1\) indicates a segment occupied by a crocodile.

Your task is to determine for each test case whether there is at least one safe segment. If there is at least one safe segment, output YES, otherwise output NO.

Note: The input is read from standard input (stdin) and the output should be written to standard output (stdout). Each test case's answer should be printed on a new line.

inputFormat

The first line contains an integer \(T\), the number of test cases. Each test case is described as follows:

  1. The first line contains an integer \(N\), the number of segments.
  2. The second line contains \(N\) space-separated integers (each integer is either 0 or 1) representing the segments.

For example:

3
5
1 0 1 1 0
4
1 1 1 1
6
0 0 1 0 1 0

outputFormat

For each test case, output a single line containing YES if at least one safe segment (0) exists in the test case. Otherwise, output NO.

For the sample input above, the correct output is:

YES
NO
YES
## sample
3
5
1 0 1 1 0
4
1 1 1 1
6
0 0 1 0 1 0
YES

NO YES

</p>