-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Strange_Splitting.cpp
More file actions
52 lines (43 loc) · 860 Bytes
/
A_Strange_Splitting.cpp
File metadata and controls
52 lines (43 loc) · 860 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
#include <bits/stdc++.h>
using namespace std;
int main(){
int t; cin >> t ;
while(t--){
int n; cin >> n;
vector<int>a(n);
unordered_map<int,bool> mp;
int distinct = 0;
for(int i=0;i<n;i++){
cin >> a[i];
if(mp[a[i]] != true){
mp[a[i]] = true; distinct++ ;
}
}
if(distinct == 1){
cout << "NO" << endl;
continue;
}
else if(distinct == n){
cout << "YES" << endl;
cout << "R";
for(int i=1;i<n;i++){
cout << "B" ;
}
cout << endl;
}
else{
cout << "YES" << endl;
cout << "R";
int i=1;
while(a[i] != a[i-1] && i < n){
cout << "R";
i++ ;
}
for(i;i<n;i++){
cout << "B";
}
cout << endl;
}
}
return 0;
}