CF 445A DZY Loves Chessboard
来源:互联网 发布:js与jquery的区别 编辑:程序博客网 时间:2024/05/04 15:36
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....
BWWB
3 3.-.-----.
B-B-----B
#include<stdio.h>int main (){int n,m;int i,j;char c[200][200];scanf("%d%d",&n,&m);getchar(); //一定要注意这个for(i=1;i<=n;i++){for(j=1;j<=m;j++) scanf("%c",&c[i][j]);getchar(); //一定要注意这个}for(i=1;i<=n;i++){for(j=1;j<=m;j++){if(c[i][j]=='-'){c[i][j]='-';}else {if(i%2!=0){if(j%2!=0) c[i][j]='W';else c[i][j]='B';}else {if(j%2!=0) c[i][j]='B';else c[i][j]='W'; }}}}for(i=1;i<=n;i++){for(j=1;j<=m;j++){if(j!=m) printf("%c",c[i][j]);else printf("%c\n",c[i][j]);}}return 0;}
- CF 445A DZY Loves Chessboard
- A. DZY Loves Chessboard (CF)
- CF 445A(DZY Loves Chessboard-BW填充)
- 【CF】DZY Loves Chessboard
- A. DZY Loves Chessboard
- A. DZY Loves Chessboard
- Codeforces 445A. DZY Loves Chessboard
- Codeforces 445A DZY Loves Chessboard
- Codeforces 445A DZY Loves Chessboard(水题)
- CodeForces 445A DZY Loves Chessboard
- CodeForces 445A DZY Loves Chessboard
- Codeforces 445A DZY Loves Chessboard
- 【Codeforces 445A DZY Loves Chessboard 】+ 思维
- CodeForcse 445A DZY Loves Chessboard
- codeforces 445 A. DZY Loves Chessboard
- Codeforces 445 A DZY Loves Chessboard(预处理)
- 【CodeForces】445A - DZY Loves Chessboard(dfs)
- 【codeforces】-445A- DZY Loves Chessboard(思维)
- linux命令2
- Linux USB驱动详解
- java中ArrayList和LinkList的区别
- linux驱动面试题目汇总
- java 中的 object.wait()和object.notify()的分析
- CF 445A DZY Loves Chessboard
- POJ 1386 Play on Words
- Remove Duplicates from Sorted List II
- 循环链表解决出圈问题java代码(已调试)
- DWZ (JUI) 教程 tree 控件的选中事件
- Combination Sum II
- python 教程收集
- Codeforces 444A. DZY Loves Physics
- uc1