-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathCodeforces_0275A_Lights_Out.java
More file actions
45 lines (44 loc) · 1.4 KB
/
Codeforces_0275A_Lights_Out.java
File metadata and controls
45 lines (44 loc) · 1.4 KB
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
37
38
39
40
41
42
43
44
45
// AC: 202 ms
// Memory: 0 KB
// .
// T:O(n^2), S:O(n^2)
//
import java.util.Scanner;
public class Codeforces_0275A_Lights_Out {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] table = new int[3][3], result = new int[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
int a = sc.nextInt();
table[i][j] = a % 2;
result[i][j] = 1;
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (table[i][j] == 1) {
result[i][j] = (result[i][j] + 1) % 2;
if (i - 1 >= 0) {
result[i - 1][j] = (result[i - 1][j] + 1) % 2;
}
if (i + 1 < 3) {
result[i + 1][j] = (result[i + 1][j] + 1) % 2;
}
if (j - 1 >= 0) {
result[i][j - 1] = (result[i][j - 1] + 1) % 2;
}
if (j + 1 < 3) {
result[i][j + 1] = (result[i][j + 1] + 1) % 2;
}
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(result[i][j]);
}
System.out.println();
}
}
}