-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF445A.java
36 lines (31 loc) · 945 Bytes
/
CF445A.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class CF445A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
char[][] matrix = new char[n][m];
for(int i = 0; i < n; i++) {
String str = sc.next();
for(int j = 0; j < m; j++) {
matrix[i][j] = str.charAt(j);
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(matrix[i][j] == '.') {
if((j + i) % 2 == 0) {
matrix[i][j] = 'B';
} else matrix[i][j] = 'W';
}
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
System.out.print(matrix[i][j]);
}
System.out.println();
}
sc.close();
}
}