Ankit_132

C

Nov 19th, 2023
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  6.  
  7. int main()
  8. {
  9.     _test
  10.     {
  11.         int n, m, k;
  12.         cin>>n>>m>>k;
  13.  
  14.         if((n+m)%2 != k%2 || n+m-2>k)
  15.         {
  16.             cout<<"No\n";
  17.             continue;
  18.         }
  19.  
  20.         string x, y;
  21.         while(x.size() < m-1)    x += 'R';
  22.         while(y.size() < m)      y += 'R';
  23.  
  24.         vector<string> r(n, x), c(n-1, y);
  25.  
  26.         r[0][0] = r[1][0] = 'R';
  27.         c[0][0] = c[0][1] = 'B';
  28.  
  29.         int f = 1;
  30.  
  31.         for(int i=1; i<n-1; i++)
  32.         {
  33.             if(f)       c[i][0] = 'R';
  34.             else        c[i][0] = 'B';
  35.  
  36.             f ^= 1;
  37.         }
  38.  
  39.         for(int j=0; j<m-1; j++)
  40.         {
  41.             if(f)       r[n-1][j] = 'R';
  42.             else        r[n-1][j] = 'B';
  43.  
  44.             f ^= 1;
  45.         }
  46.  
  47.         if(r[n-1][m-3] == 'R')
  48.             c[n-2][m-1] = c[n-2][m-2] = 'B', r[n-2][m-2]='R';
  49.         else
  50.             c[n-2][m-1] = c[n-2][m-2] = 'R', r[n-2][m-2]='B';
  51.  
  52.         cout<<"Yes\n";
  53.         for(auto e: r)
  54.         {
  55.             for(auto _: e)
  56.                 cout<<_<<" ";
  57.             cout<<"\n";
  58.         }
  59.         for(auto e: c)
  60.         {
  61.             for(auto _: e)
  62.                 cout<<_<<" ";
  63.             cout<<"\n";
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment