Advertisement
Goga21

Untitled

Jun 9th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define int long long
  4.  
  5. using namespace std;
  6.  
  7. signed main() {
  8.     int t;
  9.     cin >> t;
  10.     while(t--){
  11.         int n;
  12.         cin >> n;
  13.         vector<int> v(n);
  14.         for(int i = 0; i < n; ++i){
  15.             cin >> v[i];
  16.         }
  17.  
  18.         string ans;
  19.         ans.resize(n);
  20.  
  21.         if(v[0] == v.back()){
  22.             cout << "NO\n";
  23.         }else{
  24.             bool q = false;
  25.  
  26.             for(int i = 0; i < n; i++){
  27.                 if(v[i] != v[0] && v[i] != v.back() && !q){
  28.                     q = true;
  29.                     ans[i] = 'B';
  30.                 }else{
  31.                     ans[i] = 'R';
  32.                 }
  33.             }
  34.  
  35.             if(!q){
  36.                 ans[1] = 'B';
  37.             }
  38.             cout << "YES" << '\n' << ans << '\n';
  39.         }
  40.  
  41.        
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement