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 }

     

  • 相关阅读:
    帮助你生成分享和显示社交媒体网络按钮的jQuery插件 #50C1AL java程序员
    Storyboard多View的切换 [xcode 4.4.1]
    ObjectiveC Enum 枚举数据类型解析
    在IOS中使用KeychainItemWrapper保存用户名和密码实现记住密码功能
    10个迷惑新手的Cocoa&Objectivec开发问题
    关于分类(category)和类的扩展(extensions)的验证
    解决mac创建的压缩包,window下解压乱码的问题
    xcode快捷键大全
    解决Shockwave flash在chrome浏览器上崩溃的问题
    嵌入式内核与文件系统烧写
  • 原文地址:https://www.cnblogs.com/ahijing/p/12678508.html
Copyright © 2011-2022 走看看