Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast")
- #pragma GCC optimize("unroll-loops")
- #pragma GCC target("avx2")
- #define _CRT_SECURE_NO_WARNINGS
- #define debug(x) cerr<<" smotri huinyi : "<<#x<<' '<<x<<'\n';
- #include "bits/stdc++.h"
- //#include "geometry.h"
- //#include "data_structure.h"
- using namespace std;
- using namespace chrono;
- #define all(a) a.begin(), a.end()
- #define allr(a) a.rbegin(), a.rend()
- #define sqrt(x) sqrtl(x)
- mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
- typedef long long ll;
- typedef long double ld;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- srand(time(NULL));
- ll t = 1;
- cin >> t;
- while (t--) {
- ll n, m, b, w;
- cin >> n >> m >> b >> w;
- vector<vector<char>> a(4 * n, vector<char>(4 * m));
- a[0][0] = 'B';
- for (ll i = 0; i < 4 * n; i++){
- for (ll j = 0; j < 4 * m; j++){
- a[i][j] = 'B';
- if (i != 0 && a[i - 1][j] == 'B'){
- a[i][j] = 'W';
- }
- if (j != 0 && a[i][j - 1] == 'B'){
- a[i][j] = 'W';
- }
- }
- }
- ll cntb = 0, cntw = 0;
- vector<vector<bool>>used(4 * n, vector<bool>(4 * m, 0));
- if (b == 0) {
- if (w != 0) {
- used[0][1] = true;
- }
- for (ll i = 0; i < 4 * n; i++) {
- for (ll j = 0; j < 4 * m; j++) {
- if (used[i][j]){
- cout << a[i][j];
- }
- else{
- cout << '.';
- }
- }
- cout << '\n';
- }
- continue;
- }
- a[1][4 * m - 1] = '.';
- for (int i = 1; i < 4 * m - 2; i++){
- if (cntb == b)
- break;
- if (a[1][i] == 'B'){
- cntb++;
- used[1][i] = true;
- }
- else{
- cntw++;
- used[1][i] = true;
- }
- }
- for (ll i = 2; i < 4 * n - 2; i++) {
- for(ll j = 1; j < 4 * m - 2; j += 4) {
- if (cntw < w && !used[i][j] && a[i][j] == 'W' && a[i - 1][j] == 'B' && used[i - 1][j]) {
- cntw++;
- used[i][j] = true;
- }
- if (cntb < b && !used[i][j] && a[i][j] == 'B' && a[i - 1][j] == 'W' && used[i - 1][j]) {
- cntb++;
- used[i][j] = true;
- }
- }
- }
- for (ll i = 0; i < 4 * n; i++) {
- for (ll j = 0; j < 4 * m; j++) {
- if (!used[i][j] && a[i][j] == 'B'){
- used[i][j] = true;
- a[i][j] = '.';
- }
- }
- }
- for (ll i = 0; i < 4 * n; i++) {
- for (ll j = 0; j < 4 * m; j++) {
- if (!used[i][j]) {
- if (i > 0 && a[i - 1][j] == 'B'){
- cntw++;
- used[i][j] = true;
- if (cntw == w)
- goto print;
- }
- else if ( j > 0 && a[i][j - 1] == 'B') {
- cntw++;
- used[i][j] = true;
- if (cntw == w)
- goto print;
- }
- else if (j + 1 < 4 * m && a[i][j + 1] == 'B' ){
- cntw++;
- used[i][j] = true;
- if (cntw == w)
- goto print;
- }
- else if ( i + 1 < 4 * n && a[i + 1][j] == 'B') {
- cntw++;
- used[i][j] = true;
- if (cntw == w)
- goto print;
- }
- }
- }
- }
- print:
- for (ll i = 0; i < 4 * n; i++) {
- for (ll j = 0; j < 4 * m; j++) {
- if (used[i][j])
- cout << a[i][j];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement