编程介的小学生 2017-08-22 14:06 采纳率: 20.5%
浏览 722
已采纳

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

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误