Codeforces 445A DZY Loves Chessboard(水题)
2014-07-08 00:06
351 查看
题目连接:Codeforce 445A DZY Loves Chessboard
题目大意:给出一张n*m的图,要在'.'的位置上填B或者W,给出要求B不能和B相邻,W不能和W相邻,输出方案。
解题思路:对于'.'的位置,横纵坐标和为奇数的放B,偶数的放W。
题目大意:给出一张n*m的图,要在'.'的位置上填B或者W,给出要求B不能和B相邻,W不能和W相邻,输出方案。
解题思路:对于'.'的位置,横纵坐标和为奇数的放B,偶数的放W。
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 100; int n, m; char s[maxn+5][maxn+5]; int main () { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%s", s[i]); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) if (s[i][j] == '.') { printf("%c", (i+j)%2 ? 'W' : 'B'); } else printf("%c", s[i][j]); printf("\n"); } return 0; }
相关文章推荐
- Codeforces 644A Parliament of Berland 【水题】
- codeforces 655A A. Amity Assessment(水题)
- codeforces 652C Foe Pairs 水题
- CodeForces 705B (训练水题)
- codeforces 658A A. Bear and Reverse Radewoosh(水题)
- Codeforces 825D Suitable Replacement【贪心】水题
- CodeForces 6A Triangle(水题)
- CodeForces 709C Letters Cyclic Shift (水题)
- CodeForces 711A Bus to Udayland (水题)
- Codeforces Good Bye 2017 C. New Year and Curling(模拟水题)
- CodeForces 608A Saitama Destroys Hotel(水题)
- Codeforces 501A:Contest(水题)
- CodeForces 721A One-dimensional Japanese Crossword (水题)
- Codeforces 545D - Queue (水题)
- codeforces 676A A. Nicholas and Permutation(水题)
- CodeForces 688B Lovely Palindromes (水题回文)
- Codeforces 725 A Jumping Ball【水题】
- CodeForces 339B Xenia and Ringroad(水题模拟)
- 【打CF,学算法——二星级】CodeForces 417B Crash (水题)
- codeforces 798a Mike and palindrome 水题