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 }

     

  • 相关阅读:
    OGG for sqlserver engryption && insert/delete
    MySQL中SQL_CALC_FOUND_ROWS的用法
    VMWARE 虚拟机新增硬盘,格式化分区,并挂载
    Mycat实战之数据迁移(oracle -- mysql)
    MYCAT实战之分片迁移
    mycat实战之性能测试
    Mycat实战之主键数据库自增方式
    对象的创建与克隆
    c#调用c++的dll,错误篇
    java 模拟消息的发送功能
  • 原文地址:https://www.cnblogs.com/ahijing/p/12678508.html
Copyright © 2011-2022 走看看