题目大意:有一个冰箱门有16个把手,为4x4正方形排列,要求把所有的把手打开,每次打开或者关闭一个把手的时候,以把手为行列中心的,同一行同一列的把手都会进行状态转换。
回溯要写吐了,都没写出来
代码里是用DFS的步数num作为ans[num]来存的回溯(以后这样写!!!)
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<cmath>
using namespace std;
int map[10][10],flag=0,ans;
struct bbq
{
int x,y;
};
bbq a[20];
void change(int x,int y)//把xy的行列全部翻过来
{
map[x][y]=!map[x][y];
for(int i=1; i<=4; i++)
{
map[x][i