-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1207B.cpp
More file actions
42 lines (38 loc) · 1.09 KB
/
1207B.cpp
File metadata and controls
42 lines (38 loc) · 1.09 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
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> A(n, vector<int>(m, 0));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> A[i][j];
vector<pair<int, int>> ans;
vector<vector<int>> B(n, vector<int>(m, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i + 1 < n && j + 1 < m && A[i][j] && A[i + 1][j] && A[i][j + 1] && A[i + 1][j + 1]) {
ans.push_back({i, j});
B[i][j] = B[i + 1][j] = B[i][j + 1] = B[i + 1][j + 1] = 1;
}
}
}
bool ok = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (A[i][j] != B[i][j]) {
ok = false;
break;
}
}
}
if (!ok)
cout << -1 << endl;
else {
cout << ans.size() << endl;
for (auto& elem : ans) {
cout << elem.first + 1 << " " << elem.second + 1 << endl;
}
}
return 0;
}