Codeforces Round #254 (Div. 2):A. DZY Loves Chessboard

简介:
time limit per test
 1 second
memory limit per test
 256 megabytes
input
 standard input
output
 standard output

DZY loves chessboard, and he enjoys playing with it.

He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with the same color are on two adjacent cells. Two cells are adjacent if and only if they share a common edge.

You task is to find any suitable placement of chessmen on the given chessboard.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100).

Each of the next n lines contains a string of m characters: the j-th character of the i-th string is either "." or "-". A "." means that the corresponding cell (in the i-th row and the j-th column) is good, while a "-" means it is bad.

Output

Output must contain n lines, each line must contain a string of m characters. The j-th character of the i-th string should be either "W", "B" or "-". Character "W" means the chessman on the cell is white, "B" means it is black, "-" means the cell is a bad cell.

If multiple answers exist, print any of them. It is guaranteed that at least one answer exists.

Sample test(s)
input
1 1
.
output
B
input
2 2
..
..
output
BW
WB
input
3 3
.-.
---
--.
output
B-B
---
--B
Note

In the first sample, DZY puts a single black chessman. Of course putting a white one is also OK.

In the second sample, all 4 cells are good. No two same chessmen share an edge in the sample output.

In the third sample, no good cells are adjacent. So you can just put 3 chessmen, no matter what their colors are.


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

const int M = 1000 + 5;
char str[M][M];
int  a, b;

int main()
{
    while(scanf("%d%d", &a, &b)!=EOF)
    {
        memset(str, 0, sizeof(str));
        for(int i=1; i<=a; i++)
            for(int j=1; j<=b; j++)
                cin>>str[i][j];
        for(int i=1; i<=a; i++)
            for(int j=1; j<=b; j++)
            {
                if(str[i][j]=='.')
                {
                    if((i+j)%2==0)
                        str[i][j]='B';
                    else
                        str[i][j]='W';
                }
            }
        for(int i=1; i<=a; i++)
        {
            for(int j=1; j<=b; j++)
                cout<<str[i][j];
            cout<<endl;
        }
    }

    return 0;
}



版权声明:本文博客原创文章。博客,未经同意,不得转载。







本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4658540.html,如需转载请自行联系原作者


相关文章
|
数据挖掘 调度 开发工具
Github 2.3k star 太牛x,京东(JoyAgent‑JDGenie)这个开源项目来得太及时啦,端到端多智能体神器!!!
JoyAgent-JDGenie是京东开源的端到端产品级多智能体系统,支持自然语言生成报告、PPT、网页等内容,准确率达75.15%。具备开箱即用、多智能体协同、高扩展性及跨任务记忆能力,支持多种文件格式输出,部署灵活,不依赖私有云平台。适合企业自动化报告生成、数据分析与行业定制化应用,是高效、实用的开源AI工具。
1964 0
|
移动开发 监控 安全
【HarmonyOS Next】ArkUI-X休闲益智接水果【进阶】
本文基于ArkUI-X实现跨平台接水果游戏,深入分析HarmonyOS与iOS设备上网络图片渲染差异,并提供响应式加载、格式优化及设备适配等专业级解决方案,实现单代码库双端高效开发。
330 0
|
存储 安全 网络协议
WebDAV
WebDAV【2月更文挑战第28天】
3758 1
|
存储 算法 PyTorch
Transformers 4.37 中文文档(五十四)(3)
Transformers 4.37 中文文档(五十四)
276 0
|
机器学习/深度学习 vr&ar
矩阵的等价,相似,合同,正定判定和关系
如果矩阵可逆,那么它的逆矩阵和它的伴随矩阵之间只差一个系数。然而,伴随矩阵对不可逆的矩阵也有定义,并且不需要用到除法。
矩阵的等价,相似,合同,正定判定和关系
|
大数据 物联网 云计算
丁国祥:吉利的数字化转型从云上起步
竞争如此激烈的汽车市场,取得如此成绩不仅依靠优质的产品与出色的服务,吉利对新销售模式的思考与支撑,及其信息系统建设同样值得借鉴。
9085 0
|
3天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8095 2
|
12天前
|
域名解析 人工智能 Linux
|
20天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
10639 13
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置