-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF1972B.cpp
33 lines (33 loc) · 861 Bytes
/
CF1972B.cpp
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
#include <bits/extc++.h>
using namespace std;
namespace pbds = __gnu_pbds;
using ui = unsigned int;
using uli = unsigned long long int;
using li = long long int;
int main(void) {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
size_t T;
cin >> T;
while (T--) {
size_t n;
cin >> n;
vector<bool> a(n);
for (vector<bool>::reference i : a) {
char c;
cin >> c;
i = c == 'U';
}
bool flag = false;
while (true) {
vector<bool>::iterator it = find(a.begin(), a.end(), true);
if (it == a.end()) break;
vector<bool>::iterator pv = prev(it == a.begin() ? a.end() : it),
nt = next(it) == a.end() ? a.begin() : next(it);
*pv = !*pv, *nt = !*nt;
a.erase(it);
flag = !flag;
}
cout << (flag ? "YES" : "NO") << '\n';
}
return 0;
}