The Pilots Brothers' refrigerator 分类: POJ 2015-06-15 19:34 12人阅读 评论(0) 收藏
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
6
1 1
1 3
1 4
4 1
4 3
4 4
/*
由于变一个所在行与列都要变,所以对于是减号的转换到最后还是不变,也就是转换了偶数次,加号所在行与列一定进行转换,所以只需要统计加号所在行与列的
转化次数,偶数不用变,奇数需要变,对于奇数和变一次的效果一样。所以次数就是奇数的次数。
*/#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <algorithm>
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;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
The Pilots Brothers' refrigerator 分类: POJ 2015-06-15 19:34 12人阅读 评论(0) 收藏的更多相关文章
- IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19125 Accepted: 11053 Desc ...
- Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 108765 Accepted: 53009 Descr ...
- iOS自定义字体及类目 分类: ios技术 2015-05-15 16:34 195人阅读 评论(0) 收藏
1:获取字体文件 从各种渠道下载字体文件ttf, 网站或者从别的ipa里扣出来.(以fzltxh.ttf为例) 2:将fzltxh.ttf文件拷贝到工程中 3:在Info.plist中添加项: Fon ...
- 迷之节约 分类: sdutOJ 最小生成树 2015-06-24 19:10 10人阅读 评论(0) 收藏
迷之节约 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 FF超级有钱,最近又买了n个(1 <= n <= 300)小岛,为 ...
- Hdu 1506 Largest Rectangle in a Histogram 分类: Brush Mode 2014-10-28 19:16 93人阅读 评论(0) 收藏
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 二分图匹配 分类: ACM TYPE 2014-10-01 19:57 94人阅读 评论(0) 收藏
#include<cstdio> #include<cstring> using namespace std; bool map[505][505]; int n, k; bo ...
- Can you find it? 分类: 二分查找 2015-06-10 19:55 5人阅读 评论(0) 收藏
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...
- 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19:21 120人阅读 评论(0) 收藏
上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...
- Power Strings 分类: POJ 串 2015-07-31 19:05 8人阅读 评论(0) 收藏
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ...
随机推荐
- GTA项目 三, 使用 bootstrap table展示界面,使得data和UI分离
/** bootstrap-table - v1.5.0 - 2014-12-12* https://github.com/wenzhixin/bootstrap-table* Copyright ( ...
- application 统计网站访问人数
参考书<JSP Web 开发案例教程> index.jsp welcome.jsp 显示
- UVa 10007 - Count the Trees(卡特兰数+阶乘+大数)
题目链接:UVa 10007 题意:统计n个节点的二叉树的个数 1个节点形成的二叉树的形状个数为:1 2个节点形成的二叉树的形状个数为:2 3个节点形成的二叉树的形状个数为:5 4个节点形成的二叉树的 ...
- 点的双联通+二分图的判定(poj2942)
Knights of the Round Table Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 10804 Acce ...
- [原创]java WEB学习笔记56:Struts2学习之路---Struts 版本的 登录 demo
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- [转] 多线程 《深入浅出 Java Concurrency》目录
http://ifeve.com/java-concurrency-thread-directory/ synchronized使用的内置锁和ReentrantLock这种显式锁在java6以后性能没 ...
- [Ubuntu] Install subversion1.8 on Ubuntu13.10
Subversion1.8 is difference far away from subversion1.7, here is the steps to install subversion1.8. ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON Histogram
zw版[转发·台湾nvp系列Delphi例程]HALCON Histogram unit Unit1;interfaceuses Windows, Messages, SysUtils, Varian ...
- yii2 render和renderPartial区别
1.render()方法使用到项目中的布局layout,renderPartial()不使用布局
- Win7旗舰版中的IIS配置asp.net的运行环境
Win7旗舰版中的IIS配置asp.net的运行环境 以前弄过好多次,都没有成功,昨天晚上不知怎么地就成功了,借用我同学的一句话,这叫“灵光一闪”,废话不多说了,这个成功是有图有视频有真相地哈! ...