Codeforces Round #632 (Div. 2) A. Little Artem(水题)

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).

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

BWWBBBBWBBWWBWB我是傻逼读错题了==还以为B和W是总的数目且要求B=W+1...狂写一通感慨A题怎么这么难然后发现样例WTF....

注意这个题的B和W是与另一个颜色格子相邻的格子数目!如果不相邻的话是不会被统计在里面的。直接构造左上角是W其他是B即可。
#include <bits/stdc++.h>
using namespace std;
int t,m,n;
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        int i,j;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                if(i==1&&j==1)cout<<‘W‘;
                else cout<<‘B‘;
            }
            cout<<endl;
        }
    }
    return 0;
}

原文地址:https://www.cnblogs.com/lipoicyclic/p/12665813.html

时间: 2024-10-16 05:28:15

Codeforces Round #632 (Div. 2) A. Little Artem(水题)的相关文章

Codeforces Round #113 (Div. 2)E---Tetrahedron(矩阵,水题)

You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one

Codeforces Round #279 (Div. 2) A. Team Olympiad 水题

#include<stdio.h> #include<iostream> #include<memory.h> #include<math.h> using namespace std; int flag1[5000]; int flag2[5000]; int flag3[5000]; int main() { memset(flag1,0,sizeof(flag1)); memset(flag2,0,sizeof(flag2)); memset(flag

Codeforces Round #632 (Div. 2) 部分题解

目录 Codeforces Round #632 (Div. 2) A. Little Artem B. Kind Anton C. Eugene and an array D. Challenges in school №41 F. Kate and imperfection Codeforces Round #632 (Div. 2) A. Little Artem 题意:略. 分析:构造这样的图形: BWW...W BWW...W BBB...B #include <bits/stdc++

Codeforces Round #259 (Div. 2) (简单模拟实现题)

题目链接:http://codeforces.com/problemset/problem/454/A A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine

Codeforces Round #260 (Div. 2) A. Laptops(简单题)

题目链接:http://codeforces.com/problemset/problem/456/A A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Dima and Alex had an argument about the price and quality of laptops.

Codeforces Round #423 (Div. 2) D. High Load(构造题)

题目链接:Codeforces Round #423 (Div. 2) D. High Load 题意: 给你一个数n和k,让你构造出一颗树,有k个叶子节点,使得这棵树的任意两个点的距离的最大值最小. 题解: 显然要使得这棵树的任意两个点的距离的最大值最小,每个点离树根越近越好. 然后要求有k个叶子节点,所以我就任意选一个点为根,然后构成一棵m叉的树就行了. 最大距离的最小值就是离根最远的和最近的加一加就行了. 1 #include<cstdio> 2 #define F(i,a,b) for

[每日一题]:Codeforces Round #632 (Div. 2) C. Eugene and an array

题目: 样例: 题目大意: 给一个数组序列,问子串的和不为 0 的数量.(子串是连续的哦) 考察点: 前缀和.尺取.set的用法.思维 图解: Code: #include <set> #include <cstdio> #include <string> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef l

Codeforces Round #256 (Div. 2) A. Rewards(简单题)

题目链接:http://codeforces.com/contest/448/problem/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

Codeforces Round #561 (Div. 2) (还差2题)

总结:bitset的基本操作:http://www.cnblogs.com/RabbitHu/p/bitset.html B题中求每行每列均有...,只要在下一行中把上一行的第一个放到最后一个就能构造满足条件的解: C题中这种,如果直接讨论绝对值的情况有点多,直接自己写几个例子试试会快上很多: E题中用bitset处理这些集合是否重合特别的快,代码也很简洁: 题目链接:http://codeforces.com/contest/1166 A: 题意:自己看看,练练英语,英语太菜了 题解:签到就行