-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Its_Time_To_Duel.cpp
More file actions
64 lines (54 loc) · 868 Bytes
/
A_Its_Time_To_Duel.cpp
File metadata and controls
64 lines (54 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
if (n == 2 && arr[0] == 1 && arr[1] == 1)
{
cout << "YES" << endl;
return;
}
int z_cnt = 0;
for (int i = 0; i < n - 1; i++)
{
if (arr[i] == 0 && arr[i + 1] == 0)
{
cout << "YES" << endl;
return;
}
if (arr[i] == 0)
{
z_cnt++;
}
}
if (arr[n - 1] == 0)
{
z_cnt++;
}
if (z_cnt > 0)
{
cout << "NO" << endl;
}
else
{
cout << "YES" << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}