zoukankan      html  css  js  c++  java
  • CF A Little Artem(4月8日)

    Little Artem
    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+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 (1t201≤t≤20). Each of the next tt lines contains two integers n,mn,m (2n,m1002≤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
    2
    3 2
    3 3
    
    output
    BW
    WB
    BB
    BWB
    BWW
    BWB
    Note

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

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

    题意:就保证有  相邻白色格子 和黑色格子 比有相邻 白色格子 的 黑色格子 多一(听起来有点绕口的说)

    画个图理解

    B

    B

    B

    W

    B

    B

    B

    W

    B

    B

    B

    W

    B

    B

    B

    B

    (完美)

    上代码

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4         int t;
     5         cin>>t;
     6  while(t--){
     7      int m,n;
     8      cin>>m>>n;
     9      for(int i=1;i<m;i++){
    10          for(int j=1;j<n;j++){
    11              cout<<"B";
    12          }
    13          cout<<"W"<<'
    ';
    14      }
    15      for(int i=0;i<n;i++){
    16          cout<<"B";
    17      }cout<<'
    ';
    18  }
    19 
    20 return 0;
    21 }

     

  • 相关阅读:
    c:forTokens标签循环输出
    jsp转long类型为date,并且格式化
    spring中@Param和mybatis中@Param使用区别(暂时还没接触)
    734. Sentence Similarity 有字典数组的相似句子
    246. Strobogrammatic Number 上下对称的数字
    720. Longest Word in Dictionary 能连续拼接出来的最长单词
    599. Minimum Index Sum of Two Lists两个餐厅列表的索引和最小
    594. Longest Harmonious Subsequence强制差距为1的最长连续
    645. Set Mismatch挑出不匹配的元素和应该真正存在的元素
    409. Longest Palindrome 最长对称串
  • 原文地址:https://www.cnblogs.com/ahijing/p/12678508.html
Copyright © 2011-2022 走看看