fork download
  1. #include "iostream"
  2. #include "cstdio"
  3. #include "cmath"
  4. #include "algorithm"
  5. #include "string"
  6. #include "vector"
  7. using namespace std;
  8. int main() {
  9. int n, m;
  10. cin >> n >> m;
  11. char** x = new char*[n];
  12. for (int i = 0; i < n; ++i) {
  13. x[i] = new char[m];
  14. }
  15. for (int i = 0; i < n; i++) {
  16. for (int j = 0; j < m; j++) {
  17. cin >> x[i][j];
  18. }
  19. }char b = 'B', w = 'W',temp;
  20. for (int i = 0; i < n; i++) {
  21. for (int j = 0; j < m; j++) {
  22. if (x[i][j] == '.') {
  23. if ((j + i) % 2 == 0) {
  24. x[i][j] = 'B';
  25. }
  26. else x[i][j] = 'W';
  27. }
  28. }
  29. }
  30.  
  31. for (int i = 0; i < n; i++) {
  32. for (int j = 0; j < m; j++) {
  33. cout<< x[i][j];
  34. }
  35. cout << endl;
  36. }
  37. system("pause");
  38. return 0;
  39. }
Success #stdin #stdout #stderr 0s 15240KB
stdin
58 97
--.........-..-...............-....--..-.-.-..-.-.---.-.-...-.--..-.---.-....-...-.---..-.-.-...-
.---........--.........--------...--..--...--.-....--.-.--..--..-.....-...-.--.--.......--....-.-
.-...-.--.-..--..-..---..-.-....-...-..-....--...-.....-...-.-...-.--.-.-.---..--......-..-...-.-
--.......--......-........-....-...--..-.-.-....-.--...--...-.-.--..-..--...--.-..-....-.....--..
.-----..-...--..-..-...-.-...-.-.-.---.-...--.-..--...-..-........---.........-.--......-.-..--.-
--......-...
stdout
--BWBWBWBWB-BW-WBWBWBWBWBWBWBW-WBWB--WB-B-B-BW-W-W---W-W-WBW-W--BW-W---W-WBWB-BWB-B---BW-W-W-WBW-
W---WBWBWBWB--WBWBWBWBW--------BWB--WB--WBW--B-BWBW--B-B--WB--WB-BWBWB-BWB-B--W--BWBWBWB--WBWB-B-
B-BWB-B--W-WB--WB-BW---WB-B-BWBW-WBW-WB-BWBW--BWB-BWBWB-BWB-B-BWB-B--W-W-W---WB--WBWBWB-BW-WBW-W-
--WBWBWBW--BWBWBW-WBWBWBWB-BWBW-WBW--BW-W-W-WBWB-B--WBW--BWB-B-B--WB-BW--BWB--W-WB-BWBW-WBWBW--BW
B-----BW-WBW--BW-WB-BWB-B-BWB-B-B-B---B-BWB--W-WB--WBW-WB-BWBWBWBW---WBWBWBWBW-W--BWBWBW-W-WB--W-
--WBWBWB-BWB




















































stderr
sh: 1: pause: not found