****The Toy of Flandre Scarlet
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu
Description
As you know, Flandre Scarlet loves her elder sister Remilia Scarlet, and of course, Remilia loves Flandre, too. But because ofFlandre's unstable personality and incredible destructive power, Remilia has asked Flandre not to leave Scarlet Devil Mansion for nearly 500 years. The life of Flandre is so boring that it's no surprising that she did some unimaginable things. To solve this problem,Remilia decides to give a interesting big cubic toy to Flandre and tell her how to play so that Flandre can have fun.

The interesting toy's length is L meters, while its width is W meters and height is H meters. And, the toy can be split into L * W * Hstandard cube. The length, width and height of the standard cubes are all 1 meter.
Remilia prints a number on each standard cube. What's more, Flandre can add or subtract a same integer on two adjacent standard cube for arbitary times. Two cubes are adjacent if they share the same surface.
The goal of this game is making all the number become 0. Can you help Flandre to solve the problem to get some candies from her sisterRemilia?
Input
There are multiple test cases.
Each test case consists of two parts.
The first part contains a single line with three integers: L, W, H (1 ≤ L, W, H ≤ 4).
The second part consists of L sections. Each section consists of W lines, each line consists of H integers. In lth section, the hth integer of the wth line denotes the number in the given cube. All numbers are in range [0, 100].
There is a blank line between every two cases.
Output
One line for each case. If Flandre can success, you should print "Yes" (ignore quotes), otherwise you should print "No" (ignore quotes).
Sample Input
1 1 1
1 2 2 2
1 1
1 1
1 1
1 1
Sample Output
No
Yes
题目大意:是有L*W*H个1*1*1的小方块,堆成长L,宽W,高H的玩具。每个小方块上有一个数字,每次我们可以让某相邻的两个小方块,同时加上或减去一个相同的数字。问经过若干步后能不能使所有数字均为0。
显然可以转化成图来考虑。假设A, B, C, D依次相邻,分别对应1,2,3,4。经过三次操作,AB-1,BC+1, CD-1,可使D=D-A,A=0;通过两次操作,BC-2,CD+2,可使D=D+B,B=0;然后显然一次可使D=D-C,C=0。不难将这个规律推广到一般的情况,又原图必为连通图,可选一原点,例如(0,0,0),让其他所有点的数值通过以上步骤变为0,而加成或约减到(0,0,0)这个点上来。若最终该点值为零,则可达到目标。注意到在三维坐标系中,任意两整点间的距离要么是奇数要么是偶数,这一点可以反映在三个坐标值上。因此有下面的代码。用C写纯粹是为了Rank,不过有人已经这样干过于是只能排第二了。
代码:
#include <stdio.h> int l, w, h;
int sum[]; int main()
{
int t, i, j, k;
while(scanf("%d%d%d", &l, &w, &h) != EOF)
{
sum[] = sum[] = ;
for(i=; i<l; ++i)
{
for(j=; j<w; ++j)
{
for(k=; k<h; ++k)
{
scanf("%d", &t);
sum[(i+j+k)%] += t;//根据该点距离原点的距离进行奇偶分类。
}
}
}
if(sum[] == sum[])
printf("Yes\n");
else
printf("No\n");
}
return ;
}
****The Toy of Flandre Scarlet的更多相关文章
- BZOJ2553: [BeiJing2011]禁忌
2553: [BeiJing2011]禁忌 Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 203 Solved: ...
- BNU10806:请在此处签到
每年圣诞,ZUN都会邀请很多人到幻想乡举行联欢,今年也不例外.在联欢前,所有人需要在自己的昵称旁签到(签全名),以示出席.然后ZUN 会把大家的签到表保存下来作为纪念,以激励来年努力工作. 昵称: ...
- BZOJ2553[BeiJing2011]禁忌——AC自动机+概率DP+矩阵乘法
题目描述 Magic Land上的人们总是提起那个传说:他们的祖先John在那个东方岛屿帮助Koishi与其姐姐Satori最终战平.而后,Koishi恢复了读心的能力…… 如今,在John已经成为传 ...
- [BJOI2011]禁忌 --- AC自动机 + 矩阵优化 + 期望
bzoj 2553 [BJOI2011]禁忌 题目描述: Magic Land上的人们总是提起那个传说:他们的祖先John在那个东方岛屿帮助Koishi与其姐姐Satori最终战平.而后,Koishi ...
- 【BZOJ2553】[BeiJing2011]禁忌 AC自动机+期望DP+矩阵乘法
[BZOJ2553][BeiJing2011]禁忌 Description Magic Land上的人们总是提起那个传说:他们的祖先John在那个东方岛屿帮助Koishi与其姐姐Satori最终战平. ...
- 【bzoj2553】[BeiJing2011]禁忌
2553: [BeiJing2011]禁忌 Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 595 Solved: ...
- [BZOJ2553][BeiJing2011]禁忌 dp+AC自动机+矩阵快速幂
2553: [BeiJing2011]禁忌 Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 1206 Solved ...
- 【Mood-14】龙虎榜 活跃在github中的1000位中国开发者
Last cache created on 2015-01-07 by Github API v3. ♥ made by hzlzh just for fun. Rank Gravatar usern ...
- BZOJ - 2553 :禁忌(AC自动机+贪心+奇怪的矩阵)
Magic Land上的人们总是提起那个传说:他们的祖先John在那个东方岛屿帮助Koishi与其姐姐Satori最终战平.而后,Koishi恢复了读心的能力…… 如今,在John已经成为传说的时代, ...
随机推荐
- C#5.0支持的await格式
C#5.0支持的await格式 C#5.0引入了编译器支持的 async 和 await 关键字,这就为开发者提供了使用同步思想写异步代码的方便. 但是有些传统函数仅提供了异步回调实现,如何对其封装, ...
- 在使用simplexml_load_file()函数读取xml文件时遇到<![CDATA[]]>,怎么让其进行解析
simplexml_load_file ( '1394.xml', 'SimpleXMLElement', LIBXML_NOCDATA ); 使用这个函数里面的这两个参数
- ExtJS初接触 —— 了解 Ext Core
ExtJS初接触 —— 了解 Ext Core Ext Core是一款和jQuery媲美的轻型JS库,基于MIT许可.对于Dom的操作,我个人还是比较喜欢用jQuery.当然如果项目中用的是ExtJS ...
- 读excel时候出现java内存溢出
修改Eclipse,或MyEclipse的内存 例如MyEclipse 在window->preferences->myeclipse->application server-> ...
- JavaScript利用闭包实现模块化
利用闭包的强大威力,但从表面上看,它们似乎与回调无关.下面一起来研究其中最强大的一个:模块. function foo() { var something = "cool"; va ...
- java框架之struts2简介
一.Struts2简介 1.Struts2概述 Struts2是Apache发行的MVC开源框架.注意:它只是表现层(MVC)框架. M:model-----数据 ...
- 2016 ACM/ICPC Asia Regional Qingdao Online 1002 Cure
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
- JS-兼容
[个人汇总] 1.JS判断是否点击回车键/enter键 $(document).keypress(function(event){ var keycode = (event.keyCode ? eve ...
- Linux学习-文件和目录管理
Linux文件和目录管理 文件系统架构 1.Linux文件系统具有层级性 1)文件或者目录起始于根目录"/"成为树状结构 2)最顶层由/开始 2 ...
- 文档在线预览开源实现方案一:OpenOffice + SwfTools + FlexPaper
在文档在线预览方面,项目组之前使用的是Microsoft office web apps, 由于该方案需要按照微软License付费,项目经理要我预研一个文档在线预览的开源实现方案.仔细钻入该需求发现 ...