The Pilots Brothers' refrigerator dfs+枚举
来源:互联网 发布:红领巾知识知多少 编辑:程序博客网 时间:2024/05/21 06:49
#include<iostream> using namespace std;int num=0x3f3f3f3f;int a[10][10],b[10][10],flag;int fanzhuan(int x,int y){ a[x][y]=!a[x][y]; for(int i=0;i<4;i++) a[x][i]=!a[x][i]; for(int j=0;j<4;j++) a[j][y]=!a[j][y];}int panduan(){ for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(!a[i][j]) return 0; return 1; }struct node{ int a,b;}p[20];void dfs(int x,int y,int ans){ if(num==ans) { flag=panduan(); return; } if(flag||x>=4||y>=4) return; int fy=(y+1)%4; int fx=x+(y+1)/4; fanzhuan(x,y); dfs(fx,fy,ans+1); p[ans].x=x; p[ans].y=y; fanzhuan(x,y); dfs(fx,fy,ans); }int main(){ string s[4]; while(cin>>s[0]) { for(int i=1;i<4;i++) cin>>s[i]; for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(s[i][j]=='+') a[i][j]=0; else a[i][j]=1; flag=0; for(int i=0;i<=16;i++) { num=i; dfs(0,0,0); if(flag)break; } cout<<num<<endl; for(int i=0;i<num;i++) cout<<p[i].a+1<<" "<<p[i].b+1<<endl; }}
0 0
- POJ2965,The Pilots Brothers' refrigerator,枚举,DFS
- poj2965 The Pilots Brothers' refrigerator dfs+枚举
- The Pilots Brothers' refrigerator dfs+枚举
- (枚举)The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator【枚举+dfs】
- POJ 2965 The Pilots Brothers' refrigerator(dfs+枚举 || 规律)
- POJ 2965 The Pilots Brothers' refrigerator 枚举dfs
- POJ 2965-The Pilots Brothers' refrigerator(枚举&&DFS&&输出过程)
- POJ 2965 The Pilots Brothers' refrigerator(枚举+dfs)
- The Pilots Brothers' refrigerator(POJ 2965)(dfs枚举+状态压缩)
- POJ 2965 The Pilots Brothers' refrigerator(枚举+DFS)
- POJ 2965 The Pilots Brothers' refrigerator (DFS + 枚举)
- (枚举,dfs)The Pilots Brothers' refrigerator poj 2965
- POJ 2965 The Pilots Brothers' refrigerator(枚举+dfs)
- POJ1965 The Pilots Brothers' refrigerator(dfs,回溯,枚举)
- poj2965The Pilots Brothers' refrigerator DFS+枚举
- POJ2965 The Pilots Brothers' refrigerator 枚举
- POJ 2965 The Pilots Brothers' refrigerator 枚举
- Python SMTP发送邮件
- 第五章体检套餐
- C++派生类中如何初始化基类对象
- Mysql命令大全
- mysql sql_mode参数的合理设置
- The Pilots Brothers' refrigerator dfs+枚举
- 解决电脑能上QQ,浏览器不能上网的问题!解决无法连接到代理服务器
- centos挂在ntfs文件系统
- BM算法
- AccessibilityService
- cache的工作原理
- 贝叶斯推理
- CentOS 一键搭建 L2TP VPN 服务器
- 【Maven in action】之修改eclipse的maven默认仓库路径