A. Little Artem_牛哄哄的柯南

简介: A. Little Artem

题目链接:http://codeforces.com/contest/1333/problem/A


time limit per test


1 second


memory limit per test


256 megabytes


input


standard input


output


standard output


Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.


Artem wants to paint an n×mn×m board. Each cell of the board should be colored in white or black.


Lets BB be the number of black cells that have at least one white neighbor adjacent by the side. Let WW be the number of white cells that have at least one black neighbor adjacent by the side. A coloring is called good if B=W+1B=W+1.


The first coloring shown below has B=5B=5 and W=4W=4 (all cells have at least one neighbor with the opposite color). However, the second coloring is not good as it has B=4B=4, W=4W=4 (only the bottom right cell doesn't have a neighbor with the opposite color).


1.png


Please, help Medina to find any good coloring. It's guaranteed that under given constraints the solution always exists. If there are several solutions, output any of them.


Input


Each test contains multiple test cases.


The first line contains the number of test cases tt (1≤t≤201≤t≤20). Each of the next tt lines contains two integers n,mn,m (2≤n,m≤1002≤n,m≤100) — the number of rows and the number of columns in the grid.


Output


For each test case print nn lines, each of length mm, where ii-th line is the ii-th row of your colored matrix (cell labeled with 'B' means that the cell is black, and 'W' means white). Do not use quotes.


It's guaranteed that under given constraints the solution always exists.


Example


input


Copy

2
3 2
3 3


output


Copy

BW
WB
BB
BWB
BWW
BWB


Note


In the first testcase, B=3,W=2.


In the second testcase, B=5, W=4. You can see the coloring in the statement.



题意:n行m列的方格,每个方块旁至少一个与其颜色相反的方块,B比W多一。


代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,m;
        cin>>n>>m;
        char s[105][105];
        int ans=1; // 方便B和W交替变换
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<m; j++)
            {
                if(ans%2!=0)
                {
                    s[i][j]='B';  //先填B
                    ans++;
                }
                else
                {
                    s[i][j]='W';
                    ans++;
                }
            }
        }
        if(n*m%2!=0)  // 此时共奇数个方块,直接输出即可
        {
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                    cout<<s[i][j];
                cout<<endl;
            }
        }
        else {   // 此时共偶数个方块,此时B与W一样多,不行
            s[0][1]='B';   // B需要比W多一个,所以让前两个字符BW 变为BB
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                    cout<<s[i][j];
                cout<<endl;
            }
        }
    }
    return 0;
}



相关文章
|
6月前
|
Java
关于java获取时间 new Date(),显示“上午、下午”
关于java获取时间 new Date(),显示“上午、下午”
101 0
|
6月前
|
Java
在java java.util.Date 已知逝去时间怎么求年月日
在java java.util.Date 已知逝去时间怎么求年月日
51 0
|
SQL 安全 Java
java Date 和 Calendar类 万字详解(通俗易懂)
java API专题——常用类Date和Calender类 内容分享。
141 0
java Date 和 Calendar类 万字详解(通俗易懂)
|
数据采集 消息中间件 缓存
牛逼哄哄的 JD-hotkey !
牛逼哄哄的 JD-hotkey !
|
前端开发 小程序 Java
YourBatman表白了,在Java 27岁生日这天
Java,27周岁,我对你表白了。
111 0
YourBatman表白了,在Java 27岁生日这天
1092 最好吃的月饼(JAVA)
月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。
1092 最好吃的月饼(JAVA)
|
Java 数据库连接 mybatis
LocalDateTime、Date时间工具类
LocalDateTime、Date时间工具类
268 0
|
机器学习/深度学习 人工智能 BI
|
存储 数据采集 缓存
牛逼哄哄的 BitMap,强在哪里?
牛逼哄哄的 BitMap,强在哪里?
182 0
牛逼哄哄的 BitMap,强在哪里?