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;
}
相關文章
- codeforce 445B 並查集並查集
- codeforce959
- codeforce 888E
- codeforce 447C
- codeforce 1700-1900
- SMB與CIFS 445埠
- codeforce 277div2
- win10 445埠如何關閉 win10系統關閉445埠的方法Win10
- CF445D. Serega and Fun分塊
- win10系統怎樣關閉445埠_win10關閉445埠服務教程Win10
- Codeforce GYM 100741 A. Queries
- 445埠被封之後,如何使用smb協議協議
- windows的139埠和445埠的區別Windows
- Oracle OCP 1Z0-053 Q445Oracle
- codeforce 686div3 F Array Partition單調棧
- Win10系統關閉445埠的方法Win10
- Oracle 11G OCP 1Z0-053 445Oracle
- 【簡單菊花圖】Codeforce 1583Problem - B.md
- CMU資料庫(15-445)Lab3- QUERY EXECUTION資料庫
- CMU資料庫(15-445)Lab1-BufferPoolManager資料庫
- 【安全】如何關閉Windows系統的137, 139, 445埠?Windows
- 【L,R的特點】codeforce 822C Hacker, pack your bags!
- Codeforce演算法題 | 你能想出解法,讓你的基友少氪金嗎?演算法
- CMU資料庫(15-445)實驗2-b+樹索引實現(上)資料庫索引
- 【雲棲風向標】VOL.1:勒索病毒頻發!445埠守護指南
- CMU資料庫(15-445)-實驗2-B+樹索引實現(中)刪除資料庫索引
- [已完結]CMU資料庫(15-445)實驗2-B+樹索引實現(下)資料庫索引
- 繼勒索病毒“永恆之藍”445埠被封之後,在公網實現smb檔案共享
- Flexion:2012年1-3月使用Flexion平臺手機應用產值達445萬歐元Flex
- 任天堂第一季度財報公佈:淨利潤927.5億日元 Switch銷量445萬臺
- MetaSploit攻擊例項講解------攻擊445埠漏洞(kali linux 2016.2(rolling))(詳細)Linux
- 【躍遷之路】【688天】程式設計師高效學習方法論探索系列(實驗階段445-2019.1.7)程式設計師