solution - CF1421B
Solution
最多只能操作两次,而与
然后就可以分讨了,如果
Code
#include<iostream>
#include<cstdio>
#include<vector>
//#define int long long
#define pii pair<int,int>
#define st first
#define nd second
#define mp make_pair
#define il inline
#define pb emplace_back
using namespace std;
const int MAXN=200+5;
int n;
char p[MAXN][MAXN];
vector < pii > ans;
il void solve()
{
ans.clear();
cin>>n;
for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) cin>>p[i][j];
pair <char,char> s=mp(p[1][2],p[2][1]),t=mp(p[n-1][n],p[n][n-1]);
if(s.st==s.nd)
{
if(t.st==s.st) ans.pb(n-1,n);
if(t.nd==s.st) ans.pb(n,n-1);
}
else if(t.st==t.nd)
{
if(s.st==t.st) ans.pb(1,2);
if(s.nd==t.st) ans.pb(2,1);
}
else
{
if (s.st == '1') ans.pb(1, 2);
else ans.pb(2, 1);
if (t.st == '0') ans.pb(n - 1, n);
else ans.pb(n, n - 1);
}
cout<<ans.size()<<'\n';
for(auto i:ans) cout<<i.st<<' '<<i.nd<<'\n';
return;
}
signed main()
{
ios::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
int T;
cin>>T;
while(T--)
solve();
return 0;
}