-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Lights_Out.cpp
More file actions
41 lines (32 loc) · 889 Bytes
/
A_Lights_Out.cpp
File metadata and controls
41 lines (32 loc) · 889 Bytes
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
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
vector<vector<int>> v(3, vector<int>(3, 1));
vector<vector<int>> b(3, vector<int>(3));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
cin >> b[i][j];
}
}
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
if (b[i][j] % 2 == 1) {
v[i][j] = !v[i][j];
if (i > 0) v[i-1][j] = !v[i-1][j];
if (i < 2) v[i+1][j] = !v[i+1][j];
if (j > 0) v[i][j-1] = !v[i][j-1];
if (j < 2) v[i][j+1] = !v[i][j+1];
}
}
}
for (const auto &row : v) {
for (int val : row) {
cout << val;
}
cout << endl;
}
return 0;
}