A9449 | Inna and Huge Candy Matrix
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from $1$ to $n$ from top to bottom and the columns — from $1$ to $m$ , from left to right. We'll represent the cell on the intersection of the $i$ -th row and $j$ -th column as $(i,j)$ . Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix has $p$ candies: the $k$ -th candy is at cell $(x_{k},y_{k})$ .
The time moved closer to dinner and Inna was already going to eat $p$ of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix $x$ times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix $y$ times. And then he rotated the matrix $z$ times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.
Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!
The time moved closer to dinner and Inna was already going to eat $p$ of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix $x$ times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix $y$ times. And then he rotated the matrix $z$ times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.
Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!
输入格式
The first line of the input contains fix integers $n$ , $m$ , $x$ , $y$ , $z$ , $p$ $(1<=n,m<=10^{9}; 0<=x,y,z<=10^{9}; 1<=p<=10^{5})$ .
Each of the following $p$ lines contains two integers $x_{k}$ , $y_{k}$ $(1<=x_{k}<=n; 1<=y_{k}<=m)$ — the initial coordinates of the $k$ -th candy. Two candies can lie on the same cell.
Each of the following $p$ lines contains two integers $x_{k}$ , $y_{k}$ $(1<=x_{k}<=n; 1<=y_{k}<=m)$ — the initial coordinates of the $k$ -th candy. Two candies can lie on the same cell.
输出格式
For each of the $p$ candies, print on a single line its space-separated new coordinates.
输入输出样例
输入 #1
3 3 3 1 1 9 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3
输出 #1
1 3 1 2 1 1 2 3 2 2 2 1 3 3 3 2 3 1
Just for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:
<br></br>QWER REWQ <br></br>ASDF -> FDSA<br></br>ZXCV VCXZ<br></br>
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted