2 shunfurh shunfurh 于 2017.08.26 23:22 提问

Picture Handling

Xiaoyao likes to play with pictures very much. When he got a picture, he will use rectangle selection tool to select an area ((x1, y1) to (x2, y2), inclusively) and perform these operations:

Invert: For any pixel with value v in selected area, change v to -v.
Lighten: For any pixel with value v in selected area, increase v by 1.
Darken: For any pixel with value v in selected area, decrease v by 1.
Flip Horizontal: For any pixel at (x, y) in selected area, replace its value with pixel at (x1 + x2 - x, y).
Flip Vertical: For any pixel at (x, y) in selected area, replace its value with pixel at (x, y1 + y2 - y).
After several operations, Xiaoyao wonders what value a pixel at specified position is. Could you tell him?

Input

There are multi cases (no more than 5). Please proceed to the end of input. Each case is like below:

The first line contains two integers W and H, indicating the width and height of the picture. W and H are both between 1 and 255, inclusively.

Following H lines, each line contains W integers, indicating the value of pixels. The first integer of the first line in these H lines is the value of pixel at (0, 0) and the last integer is the value of pixel at (W-1, H-1). All these values are between -105 and 105, inclusively.

Then, a line with one integer M(0 <= M <= 105).

Following M lines, each line contains 5 integers: x1 y1 x2 y2 op, indicating the selected area and the operation. (0 <= x1 <= x2 < W, 0 <= y1 <= y2 < H, 1 <= op <= 5). If op is 1, it means Invert operation. If op is 2, it means Lighten operation. The others follow by analogy. You should follow the order of the input to perform operations.

Finally, there is a line with two integers x and y. (0 <= x < W, 0 <= y < H) Your task is to output the value of pixel at (x, y) after performing above operations.

Output

For each case, output a single line containing one integer which is the value of pixel at (x, y) at last.

Sample Input

3 2
1 2 3
4 5 6
2
0 0 1 1 1
1 0 2 1 4
2 1
Sample Output

-5

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.10 08:44
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
ZOJ 3347 Picture Handling
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3347 Picture Handling Time Limit: 1 Second      Memory Limit: 32768 KB Xiaoyao likes to play with pictures very much. When he
Alignment trap的问题
在arm linux下,碰到如下错误。百度了一下,you Alignment trap: not handling instruction e1923f9f at []
RuntimeWarning: Parent module 'settings' not found while handling absolute import
运行一个脚本,产生如下报错: RuntimeWarning: Parent module 'settings' not found while handling absolute import import os 检查代码逻辑,觉得没有问题。只好上网查解决办法,查到这么一段: 就是用imp导入模块的时候,不要加 "点"。 Don't include a '.' aft
spring mvc使用MultiActionController时发生No request handling method with name的错误
spring mvc使用MultiActionController时发生No request handling method with name '方法 名' in class [类名]的错误 首先先检查一下自己编写的方法是否包含两个 参数HttpServletRequest request,HttpServletResponse response的参数,如果没有的话,就会报上面的错误。
Java Exception Handling -java异常处理
Java  Exception Handling -java异常处理 java中的异常 异常是程序在编译时或者运行时出现的意想不到的场景,比如在书写java代码时候不遵守java语法规则会导致编译失败,操作数组,下标越界的运行时异常等等。当异常发生时会导致程序异常退出,为了避免程序异常退出,我们必须对出现的某些异常处理,让程序继续执行下去,俗称“异常恢复”。 java中异常的
unittest RuntimeWarning: Parent module XX not found while handling absolute import
Pycharm执行单元测试遇到如下问题: RuntimeWarning: Parent module ‘’ not found while handling absolute import 解决方法,使用旧的utrunner.py文件替换当前版本,文件路径为…/PyCharm.app/Contents/helpers/pycharm/utrunner.py(mac平台)或者…\J
kafka 报 Error when handling request {topics=[test]} (kafka.server.KafkaApis)kafka.admin.AdminOperati
部署kafa的启动时候碰到一个问题 kafka.admin.AdminOperationException: replication factor: 1 larger than available brokers: 0 经过排查可能有如下几种原因: 1:客户端连接kafka server,但kafka server此时可能未完全启动,会在kafka server启动时抛出这个错误。
使用quartz时,遇见 "missed their scheduled fire-time"
如果你在用quartz的时候,也看到这个日志信息(Handling 2 trigger(s) that missed their scheduled fire-time.)了,并且发现quartz管理的任务,都不再被触发了,那么,你可以看看这篇文章。 原文地址: http://java.dzone.com/articles/quartz-scheduler-misfire 由于本人
解决 RuntimeWarning: Parent module '...' not found while handling absolute import
Pycharm 升级到 2016.3 以后运行 unittest 报错。报错信息:RuntimeWarning: Parent module '...' not found while handling absolute import import sys RuntimeWarning: Parent module '...' not found while handling absolute
!MESSAGE Error occurred during status handling
问题: eclipse 未响应后强制关闭,之后打开eclipse一闪而过,查看.metadata中日志报错: !ENTRY org.eclipse.ui 4 0 2014-12-22 12:21:33.259 !MESSAGE Error occurred during status handling !STACK 0 java.lang.NullPointerException at