-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
40 lines (36 loc) · 1.08 KB
/
Copy pathB.cpp
File metadata and controls
40 lines (36 loc) · 1.08 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
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const auto INIT = [] { return ios::sync_with_stdio(false), cin.tie(nullptr); }();
#define ERR(a...) fprintf(stderr, a)
constexpr int N = 210;
char s[N][N];
int main() {
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
auto a = s[0][1], b = s[1][0], c = s[n - 1][n - 2], d = s[n - 2][n - 1];
vector<pair<int, int>> ans;
if (int{a == '0'} + int{b == '0'} + int{c == '1'} + int{d == '1'} <= 2) {
if (a == '0') ans.emplace_back(1, 2);
if (b == '0') ans.emplace_back(2, 1);
if (c == '1') ans.emplace_back(n, n - 1);
if (d == '1') ans.emplace_back(n - 1, n);
} else {
if (a == '1') ans.emplace_back(1, 2);
if (b == '1') ans.emplace_back(2, 1);
if (c == '0') ans.emplace_back(n, n - 1);
if (d == '0') ans.emplace_back(n - 1, n);
}
cout << ans.size() << '\n';
for (auto &p : ans) {
cout << p.first << ' ' << p.second << '\n';
}
}
return 0;
}