POJ-2965-The Pilots Brothers' refrigerator-2013-12-05 11:18:12
来源:互联网 发布:php返回数据格式 编辑:程序博客网 时间:2024/06/11 04:36
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 iand 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>char s[4][4];int mark[4][4];int main(){int i,j,k,ni[16],nj[16];memset(mark,0,sizeof(mark));memset(s,0,sizeof(s));for(i=0;i<4;i++){for(j=0;j<4;j++){scanf("%c",&s[i][j]);}getchar();}for(i=0;i<4;i++){for(j=0;j<4;j++){if(s[i][j] == '+'){mark[i][j] = !mark[i][j];for(k=0;k<4;k++){if(k!=j)mark[i][k] = !mark[i][k];if(k!=i)mark[k][j] = !mark[k][j];}}}}k = 0;for(i=0;i<4;i++){for(j=0;j<4;j++){if(mark[i][j] == 1){ni[k] = i+1;nj[k] = j+1;k++;}}}printf("%d\n",k);for(i=0;i<k;i++){printf("%d %d\n",ni[i],nj[i]);}return 0;}
- POJ-2965-The Pilots Brothers' refrigerator-2013-12-05 11:18:12
- 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 枚举
- POJ1753 Flip Game【DFS】
- TabControl闪烁的题目
- 长尾词和目标词的优化选择
- Android AIDL使用详解
- Oracle对SQL语句处理过程
- POJ-2965-The Pilots Brothers' refrigerator-2013-12-05 11:18:12
- 推荐一款安卓软件:爱家定位,及时定位知道老人和小孩的位置防走失
- 我理解的逻辑地址、线性地址、物理地址和虚拟地址
- C++中基类中应该有虚析构函数
- 2014.1.11 【数据库】约束
- 黑马程序员------------------集合
- Android中用广播从Service中向Activity发送信息
- 【JS】全局对象(全局作用域) 内置对象挂到全局对象上,全局对象本身也挂到全局对象
- 文件系统实时监控