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 ...
随机推荐
- 模拟退火法(吊打XXX)Bzoj3680
3680: 吊打XXX Time Limit: 10 Sec Memory Limit: 128 MBSec Special Judge Submit: 308 Solved: 94 [Subm ...
- csuoj 1395: Timebomb
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1395 1395: Timebomb Time Limit: 1 Sec Memory Limit ...
- Java基础(5):试用Array类对数据进行操作(Sort和toString方法)
Arrays 类是 Java 中提供的一个工具类,在 java.util 包中.该类中包含了一些方法用来直接操作数组,比如可直接实现数组的排序.搜索等 1. 排序 语法: Arrays.sort(数 ...
- cordova3.X 运用grunt生成plugin自定义插件骨架
Cordova提供了一组设备相关的API,通过这组API,移动应用能够以JavaScript访问原生的设备功能,如摄像头.麦克风等.Cordova还提供了一组统一的JavaScript类库,以及为这些 ...
- 深入剖析PHP输入流 php://input (转载 http://www.nowamagic.net/academy/detail/12220520)
http://www.nowamagic.net/academy/detail/12220520
- python入门语法总结 zz
http://renjie120.iteye.com/blog/680126 1.python是一个解释性语言: 一个用编译性语言比如C或C++写的程序可以从源文件(即C或C++语言)转换到一个你的计 ...
- RobotFramework 安装配置(一)
服务器接口的测试框架的选择,最后选中了 RobotFramework ,原因一:能有效的管理测试用例,,支持批量执行,能实现关键字驱动或者数据驱动.原因二:支持测试人员可以使用Python和java创 ...
- Ceph的客户端安装
Contents [hide] 1 参考 1.1 ceph端口访问控制 1.2 用Kernel方式挂载 1.2.1 安装ELRepo及kernel-lt 1.2.2 修改Grub引导顺序并重启动 1. ...
- lamp环境编译(apache2.4.7 php5.4.25 mysql 5.5.23)
环境要求 gcc.gcc-c++.cmake.bison(可能)支持 1.yum install gcc gcc-c++ cmake bison 2.修改yum配置,达到搜索本地设置 移走或改名/et ...
- Delphi内嵌汇编语言BASM精要(转帖)
1 BASM概念简要 汇编语句由指令和零至三个表达式构成.表达式由常数(立即数).寄存器和标识符构成.例如: movsb // 单指令语句 jmp @Here // 一个表达式: ...