博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Pilots Brothers' refrigerator 分类: ...
阅读量:4709 次
发布时间:2019-06-10

本文共 2195 字,大约阅读时间需要 7 分钟。

The Pilots Brothers' refrigerator
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 20304   Accepted: 7823   Special Judge

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/*由于变一个所在行与列都要变,所以对于是减号的转换到最后还是不变,也就是转换了偶数次,加号所在行与列一定进行转换,所以只需要统计加号所在行与列的转化次数,偶数不用变,奇数需要变,对于奇数和变一次的效果一样。所以次数就是奇数的次数。*/
#include 
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;char s;int Arr[5][5];int main(){ int sum=0; memset(Arr,0,sizeof(Arr)); for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { cin>>s; if(s=='+') { for(int k=0; k<4; k++) { Arr[i][k]++; Arr[k][j]++; } Arr[i][j]--; } } } sum=0; for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { sum+=(Arr[i][j]%2); } } printf("%d\n",sum); for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { if(Arr[i][j]%2) { printf("%d %d\n",i+1,j+1); } } } return 0;}

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/juechen/p/4722029.html

你可能感兴趣的文章
(转)Excel的 OleDb 连接串的格式(连接Excel 2003-2013)
查看>>
Java并发编程
查看>>
Git Stash用法
查看>>
sql server 2008学习8 sql server存储和索引结构
查看>>
Jquery radio选中
查看>>
memcached 细究(三)
查看>>
RSA System.Security.Cryptography.CryptographicException
查看>>
webservice整合spring cxf
查看>>
[解题报告] 100 - The 3n + 1 problem
查看>>
Entity Framework 学习高级篇1—改善EF代码的方法(上)
查看>>
Mybatis逆向工程配置文件详细介绍(转)
查看>>
String类的深入学习与理解
查看>>
不把DB放进容器的理由
查看>>
OnePage收集
查看>>
Java parseInt()方法
查看>>
yahoo的30条优化规则
查看>>
[CCF2015.09]题解
查看>>
[NYIST15]括号匹配(二)(区间dp)
查看>>
json_value.cpp : fatal error C1083: 无法打开编译器生成的文件:No such file or directory
查看>>
洛谷 P1101 单词方阵
查看>>