POJ 2965:The Pilots Brothers' refrigerator:棋盘题目2
来源:互联网 发布:优化农业产业结构 编辑:程序博客网 时间:2024/06/06 21:07
Description
The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.
There are 16 handles on the refrigerator door. Every handle can be in one of two states: open or closed. The refrigerator is open only when all handles are open. The handles are represented as a matrix 4х4. You can change the state of a handle in any location [i, j] (1 ≤ i, j ≤ 4). However, this also changes states of all handles in row i and all handles in column j.
The task is to determine the minimum number of handle switching necessary to open the refrigerator.
Input
The input contains four lines. Each of the four lines contains four characters describing the initial state of appropriate handles. A symbol “+” means that the handle is in closed state, whereas the symbol “−” means “open”. At least one of the handles is initially closed.
Output
The first line of the input contains N – the minimum number of switching. The rest N lines describe switching sequence. Each of the lines contains a row number and a column number of the matrix separated by one or more spaces. If there are several solutions, you may give any one of them.
Sample Input
-+-----------+--
Sample Output
61 11 31 44 14 34 4
Source
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<string.h>int a[5][5],b[5][5],heng[5],shu[5],num;char t[5];void init(){int i,j;int m,n;memset(heng,0,sizeof(heng));memset(shu,0,sizeof(shu));for(i=1;i<=4;i++){scanf("%s",t);for(j=0;j<4;j++){if(t[j]=='+'){a[i][j+1]=1;heng[i]=(heng[i]+1)%2;shu[j+1]=(shu[j+1]+1)%2;}elsea[i][j+1]=0;}}num=0;}void print(){int i,j;printf("%d\n",num);for(i=1;i<=4;i++)for(j=1;j<=4;j++)if(b[i][j])printf("%d %d\n",i,j);}int main(){int i,j;init();for(i=1;i<=4;i++){for(j=1;j<=4;j++){b[i][j]=(a[i][j]+heng[i]+shu[j])%2;if(b[i][j])num++;}}print();return 0;}
- POJ 2965:The Pilots Brothers' refrigerator:棋盘题目2
- 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
- 抱歉
- VS的常用快捷键如下:
- scrapy安装方法(windows以及linux)
- duilib : write text on richedit
- {A} + {B}
- POJ 2965:The Pilots Brothers' refrigerator:棋盘题目2
- Linux环境进程间通信——消息队列
- 有很大的关系的网站关键词的排名和网站内容
- Tkprof
- 经典换路前后的电路计算
- 谓词
- Shrinking Database Segments Online
- Heritage from father
- 帝国CMS不调用指定栏目的信息不调用屏蔽指定栏目内的信息不调用出来