标签:problem bit display others main event open 技术 hid
AcWing
$Sol$
假设改变$[x1,y1]$和$[x2,y2]$的状态就可以达到目的.注意到先改变谁对结果是没有影响的!!
所以就可以直接枚举改变状态的结点而不需要注意顺序.
$4*4$的矩阵,看成一个十六位的二进制数,枚举这个二进制数就是枚举方案了.
$over!$
$Code$
#include#define il inline
#define Rg register
#define go(i,a,b) for(Rg int i=a;i#define yes(i,a,b) for(Rg int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define db double
using namespace std;
il int read()
{
Rg int x=0,y=1;char c=getchar();
while(c‘0‘||c>‘9‘){if(c==‘-‘)y=-1;c=getchar();}
while(c>=‘0‘&&c‘9‘){x=(x1)+(x3)+c-‘0‘;c=getchar();}
return x*y;
}
bool mp[5][5],nw[5][5];
int as=1e7,ans[20],tmp[20];
il void sol(int x)
{
go(i,1,4)go(j,1,4)nw[i][j]=mp[i][j];
Rg int sum=0;
go(k,1,16)
if((11)&x)
{
tmp[++sum]=k;
Rg int h=(k-1)/4+1,l=k-4*(h-1);
go(i,1,4)nw[i][l]^=1;
go(j,1,4)if(j!=l)nw[h][j]^=1;
}
go(i,1,4)go(j,1,4)if(!nw[i][j])return;
if(sumas){as=sum;go(i,1,sum)ans[i]=tmp[i];}
}
int main()
{
go(i,1,4)
{
string s;cin>>s;
go(j,1,4)if(s[j-1]==‘-‘)mp[i][j]=1;
}
Rg int maxs=(116)-1;
go(i,0,maxs)sol(i);
printf("%d\n",as);
go(i,1,as)printf("%d %d\n",(ans[i]-1)/4+1,(ans[i]%4)==0?4:ans[i]%4);
return 0;
}
View Code
$Poj2956/AcWing116\ The\ Pilots\ Brothers'Refrigerator$ 二进制
标签:problem bit display others main event open 技术 hid
原文地址:https://www.cnblogs.com/forward777/p/11279239.html