二进制串的储存是个细节比较多的问题qaq
然后各个位置的查询也有些地方要注意
这次真的是改到吐了qwq
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
int t[1<<18],fax[1<<18],fay[1<<18],fa[1<<18],y[1<<18],a[20];
bool vis[1<<20];
void cou(int x){
int t1=x/4+1,t2=x%4+1;
cout<<t1<<" "<<t2<<" ";
}
void pr(int x){
if (!fa[x]) return ;
pr(fa[x]);
cou(fax[x]),cou(fay[x]);
cout<<endl;
}
int main(){
int x;
int ch=0,zh=0;
for (int i=1;i<=16;++i) scanf ("%1d",&a[i]);
for (int i=16;i>=1;--i){
ch<<=1;
ch|=a[i];
}
for (int i=1;i<=16;++i) scanf ("%1d",&a[i]);
for (int i=16;i>=1;--i){
zh<<=1;
zh|=a[i];
}
t[1]=ch;
int h=0,ta=1,q,p;
while (h<ta){
int x=t[++h];
vis[x]=1;
int flag=0;
int to=ch;
for (int i=0;i<16;++i){
if (i<12) {
if ((x&(1<<i))&&(!(x&(1<<i+4)))) to=x&(~(1<<i)),to|=(1<<i+4);
else if ((x&(1<<i+4))&&(!(x&(1<<i)))) to=x&(~(1<<i+4)),to|=(1<<i);
if (!vis[to]) t[++ta]=to,vis[to]=1,fa[to]=x,fax[to]=i,fay[to]=i+4,y[to]=y[x]+1;
}
if (to==zh){flag=1;break;}
if (i!=3&&i!=7&&i!=11&&i!=15){
if ((x&(1<<i))&&(!(x&(1<<i+1)))) to=x&(~(1<<i)),to|=(1<<i+1);
else if ((x&(1<<i+1))&&(!(x&(1<<i)))) to=x&(~(1<<i+1)),to|=(1<<i);
if (!vis[to]) t[++ta]=to,vis[to]=1,fa[to]=x,fax[to]=i,fay[to]=i+1,y[to]=y[x]+1;
}
if (to==zh){flag=1;break;}
}
if (flag) {q=to;break;}
}
cout<<y[q]<<endl;
pr(q);
return 0;
}