-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
131 lines (98 loc) · 1.79 KB
/
B.cpp
File metadata and controls
131 lines (98 loc) · 1.79 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;
void solve(int t)
{
ll n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++) cin >> s[i];
vector<char> v, v1, v2;
vector<pair<ll, ll> > d;
v.pb(s[0][1]);
v.pb(s[1][0]);
v.pb(s[0][2]);
v.pb(s[1][1]);
v.pb(s[2][0]);
d.pb({0, 1});
d.pb({1, 0});
d.pb({0, 2});
d.pb({1, 1});
d.pb({2, 0});
v1.pb('0');
v1.pb('0');
v1.pb('1');
v1.pb('1');
v1.pb('1');
v2.pb('1');
v2.pb('1');
v2.pb('0');
v2.pb('0');
v2.pb('0');
ll cnt1 = 0, cnt2 = 0;
for (int i = 0; i < v.size(); i++)
{
if (v[i] != v1[i]) cnt1++;
if (v[i] != v2[i]) cnt2++;
}
//cout << cnt1 << " " << cnt2 << endl;
if (cnt1 <= 2)
{
cout << cnt1 << endl;
for (int i = 0; i < v.size(); i++)
{
if (v[i] != v1[i])
{
cout << d[i].F + 1 << " " << d[i].S + 1 << endl;
}
}
return;
}
if (cnt2 <= 2)
{
cout << cnt2 << endl;
for (int i = 0; i < v.size(); i++)
{
if (v[i] != v2[i])
{
cout << d[i].F + 1 << " " << d[i].S + 1 << endl;
}
}
return;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++)
{
solve(i);
}
}