Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     cin >> t;
  9.     while(t--)
  10.     {
  11.         int n,m;
  12.         cin >> n >> m;
  13.         if(n == 2 && m == 3)
  14.         {
  15.             cout << "BBW" << endl << "BWB" << endl;
  16.             continue;
  17.         }
  18.         if(n == 2)
  19.         {
  20.             cout << "BB";
  21.             bool black = true;
  22.             for(int i=1;i<=m-2;i++)
  23.             {
  24.                 if(black) {cout<<"B";black=false;}
  25.                 else {cout<<"W";black=true;}
  26.             }
  27.             black = true;
  28.             cout << endl;
  29.             for(int i=1;i<=m-1;i++)
  30.             {
  31.                 if(black) {cout<<"B";black=false;}
  32.                 else {cout<<"W";black=true;}
  33.             }
  34.             cout << "W" << endl;
  35.             continue;
  36.         }
  37.         if(m % 2 == 0)
  38.         {
  39.             for(int i=1;i<n;i++)
  40.             {
  41.                 bool black = true;
  42.                 for(int j=1;j<=m;j++)
  43.                 {
  44.                     if(black) {cout<<"B";black=false;}
  45.                     else {cout<<"W";black=true;}
  46.                 }
  47.                 cout << endl;
  48.             }
  49.             cout << "BB";
  50.             bool black = true;
  51.             for(int j=1;j<=m-2;j++)
  52.             {
  53.                 if(black) {cout<<"B";black=false;}
  54.                 else {cout<<"W";black=true;}
  55.             }
  56.             cout << endl;
  57.         }
  58.         else
  59.         {
  60.             for(int i=1;i<=n;i++)
  61.             {
  62.                 bool black = true;
  63.                 for(int j=1;j<=m;j++)
  64.                 {
  65.                     if(black)
  66.                     {
  67.                         if(j==m && i>=3)
  68.                         {
  69.                             cout << "W";
  70.                             black = false;
  71.                         }
  72.                         else
  73.                         {
  74.                             cout<<"B";
  75.                             black=false;
  76.                         }
  77.                     }
  78.                     else {cout<<"W";black=true;}
  79.                 }
  80.                 cout << endl;
  81.             }
  82.         }
  83.        
  84.     }
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement