codeforce 445 A
http://codeforces.com/problemset/problem/445/A
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.
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 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.
1 1 .
B
2 2 .. ..
BW WB
3 3 .-. --- --.
B-B --- --B
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 <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
char a[102][102];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
getchar();
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
scanf("%c",&a[i][j]);
getchar();
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(a[i][j]=='.')
{
if((i+j)%2==0)
a[i][j]='W';
else
a[i][j]='B';
}
printf("%c",a[i][j]);
}
printf("\n");
}
}
return 0;
}
相關文章
- codeforce959
- codeforce 1700-1900
- SMB與CIFS 445埠
- win10 445埠如何關閉 win10系統關閉445埠的方法Win10
- 【簡單菊花圖】Codeforce 1583Problem - B.md
- codeforce 686div3 F Array Partition單調棧
- CF445D. Serega and Fun分塊
- win10系統怎樣關閉445埠_win10關閉445埠服務教程Win10
- 【躍遷之路】【445天】刻意練習系列204(2018.04.26)
- Win10系統關閉445埠的方法Win10
- CMU資料庫(15-445)Lab1-BufferPoolManager資料庫
- CMU資料庫(15-445)Lab3- QUERY EXECUTION資料庫
- Codeforce演算法題 | 你能想出解法,讓你的基友少氪金嗎?演算法
- CMU資料庫(15-445)實驗2-b+樹索引實現(上)資料庫索引
- Gartner:2019年全球公共雲 IaaS市場達到445億美元 同比增長37.3%
- CMU資料庫(15-445)-實驗2-B+樹索引實現(中)刪除資料庫索引
- [已完結]CMU資料庫(15-445)實驗2-B+樹索引實現(下)資料庫索引
- Gartner:2019年全球IaaS公共雲服務總價值達到445億美元 同比增長37.3%
- 繼勒索病毒“永恆之藍”445埠被封之後,在公網實現smb檔案共享
- 【躍遷之路】【688天】程式設計師高效學習方法論探索系列(實驗階段445-2019.1.7)程式設計師
- 任天堂第一季度財報公佈:淨利潤927.5億日元 Switch銷量445萬臺
- IDC:2020年中國第三季度PC市場總出貨量達到1,445 萬臺 同比增長10.1%