poj 2965 The Pilots Brothers' refrigerator--棋盘--深搜
来源:互联网 发布:怎么看淘宝抢购前100 编辑:程序博客网 时间:2024/06/05 00:51
/*深搜简单,但是不熟练,犯了很多错误(七个)*/#include<stdio.h>char map[5][5];int i;int e=0;int step[20],st=0;int check(){if(e==0)return 1;return 0;}void zhi(int x,int y){int i;for(i=0;i<4;i++){e^=(1<<(x*4+i));//1.刚开始没用位操作,超时e^=(1<<(i*4+y));}e^=(1<<(x*4+y));}int d(int num,int bu){if(bu==i){if(check())return 1;else return 0;}if(num>33)//2.忘记了,有可能步数还没有达到搜索深度,已经出界了return 0;int x=num/10,y=num%10,xx=x,yy=y;zhi(x,y);yy=yy+1;xx+=yy/4;yy=yy%4;//3.曾写成yy=y%4;if(d(xx*10+yy,bu+1)){step[st++]=x*10+y;return 1;}zhi(x,y);if(d(xx*10+yy,bu)){return 1;//4.有种想要加step[st++]=x*10+y;的冲动}return 0;}int main(){int j,k;for(i=0;i<4;i++)gets(map[i]);for(j=0;j<4;j++)for(k=0;k<4;k++)if(map[j][k]=='+'){e+=(1<<(j*4+k));}if(check()){printf("0\n");return 0;}for(i=1;i<17;i++){if(d(0,0))break;}printf("%d\n",st);//5.忘了写st这个参数st--;while(st>=0){printf("%d %d\n",step[st]/10+1,step[st]%10+1);//6.忘记行号和列号都比实际情况小1st--;//7.忘记此行}return 0;}
- poj 2965 The Pilots Brothers' refrigerator--棋盘--深搜
- POJ 2965 The Pilots Brothers' refrigerator 深搜
- POJ 2965:The Pilots Brothers' refrigerator:棋盘题目2
- poj 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator
- poj 2965The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator 枚举
- POJ-2965-The Pilots Brothers' refrigerator
- poj 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator
- poj 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator
- POJ-2965-The Pilots Brothers' refrigerator
- poj 2965 The Pilots Brothers' refrigerator
- POJ 2965:The Pilots Brothers' refrigerator
- Poj 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator(枚举)
- HTTP详解(转载)
- 在.net framework 2 中使用linq to xml
- hdu 2073 无限的路
- 123
- html 小小细节...
- poj 2965 The Pilots Brothers' refrigerator--棋盘--深搜
- (笔记)巧妙清除错误输入
- SNMP简介
- iPhone UItableView cell 自适应高度
- 抽象类与接口的区别
- Java与C++以及C语言各有什么区别
- I/O体系结构和设备驱动程序(二)
- SNMP之MIB管理信息库
- VC 单选按钮 Group