poj 2965_The Pilots Brothers' refrigerator
来源:互联网 发布:linux下使用anaconda 编辑:程序博客网 时间:2024/05/16 00:28
枚举
#include<cstdio>#include<iostream>#include<cstring>using namespace std;char str[10][10];int map[10][10];void copy(){for(int i=1;i<=4;i++)for(int j=1;j<=4;j++)if(str[i-1][j-1]=='-')map[i][j]=1;elsemap[i][j]=0;}int judge(){for(int i=1;i<=4;i++)for(int j=1;j<=4;j++)if(map[i][j]==0)return 0;return 1;}void change(int k){int x=k/4;int y=k%4;for(int i=1;i<=4;i++){map[i][y+1]^=1;map[x+1][i]^=1;}map[x+1][y+1]^=1;}void print(int num,int t){printf("%d\n",num);int k=0;while(t){if(t&1){num++;int x=k/4;int y=k%4;printf("%d %d\n",x+1,y+1);}k++;t>>=1;}}int main(){while(cin>>str[0]){for(int i=1;i<4;i++)cin>>str[i];for(int i=0;i<(1<<16);i++){copy();int t=i;int num=0;int k=0;while(t){if(t&1){num++;change(k);}k++;t>>=1;}if(judge()){print(num,i);break;}}}return 0;}
- poj 2965_The Pilots Brothers' refrigerator
- 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(枚举)
- poj 2965 The Pilots Brothers' refrigerator
- POJ 2965 The Pilots Brothers' refrigerator 枚举
- 通过Linux理解操作系统(一):概述
- HRBUST 1377 分组背包
- 木桶理论
- poj4011
- Android CountDownTimer 定时器
- poj 2965_The Pilots Brothers' refrigerator
- 【leetcode】Palindrome Number
- Linux进程等待
- 马太效应
- iOS中如何创建一个滑出式导航面板(1)
- hdu 3723 Delta Wave(卡特兰数)
- 鸟笼逻辑
- ZOJ1872Freckles(MST)
- http://www.w3schools.com/