knightnemo commited on
Commit
f85c802
·
verified ·
1 Parent(s): 5cd79c8

Upload code_segments/segment_374.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_374.txt +25 -0
code_segments/segment_374.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Alice and Bob are playing a game. There is a list of $n$ booleans, each of which is either true or false, given as a binary string $^{\text{∗}}$ of length $n$ (where $\texttt{1}$ represents true, and $\texttt{0}$ represents false). Initially, there are no operators between the booleans.
2
+
3
+ Alice and Bob will take alternate turns placing and or or between the booleans, with Alice going first. Thus, the game will consist of $n-1$ turns since there are $n$ booleans. Alice aims for the final statement to evaluate to true, while Bob aims for it to evaluate to false. Given the list of boolean values, determine whether Alice will win if both players play optimally.
4
+
5
+ To evaluate the final expression, repeatedly perform the following steps until the statement consists of a single true or false:
6
+
7
+ * If the statement contains an and operator, choose any one and replace the subexpression surrounding it with its evaluation. * Otherwise, the statement contains an or operator. Choose any one and replace the subexpression surrounding the or with its evaluation.
8
+
9
+ For example, the expression true or false and false is evaluated as true or (false and false) $=$ true or false $=$ true. It can be shown that the result of any compound statement is unique.
10
+
11
+ $^{\text{∗}}$A binary string is a string that only consists of characters $\texttt{0}$ and $\texttt{1}$
12
+
13
+ The first line contains $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
14
+
15
+ The first line of each test case contains an integer $n$ ($2 \leq n \leq 2 \cdot 10^5$) — the length of the string.
16
+
17
+ The second line contains a binary string of length $n$, consisting of characters $\texttt{0}$ and $\texttt{1}$ — the list of boolean values.
18
+
19
+ It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
20
+
21
+ For each testcase, output "YES" (without quotes) if Alice wins, and "NO" (without quotes) otherwise.
22
+
23
+ You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).
24
+
25
+ In the first