您的位置:首页 > 其它

Codeforces 400C Inna and Huge Candy Matrix 【模拟】

2016-03-21 23:47 477 查看
题目链接:Codeforces 400C Inna and Huge Candy Matrix

题意:给定矩阵中某些元素的位置,问经过x次顺时针旋转、y次水平旋转、z次逆时针旋转后元素的位置。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#define PI acos(-1.0)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define fi first
#define se second
#define ll o<<1
#define rr o<<1|1
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 500 + 10;
const int pN = 1e6;// <= 10^7
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
void add(LL &x, LL y) { x += y; x %= MOD; }
int u, v, n, m;
void Solve(int x, int y, int z) {
int row = n, cul = m;
int nx, ny;
for(int i = 1; i <= x; i++) {
nx = v;
ny = row - u + 1;
u = nx;
v = ny;
swap(row, cul);
//cout << u << " " << v << endl;
}
for(int i = 1; i <= y; i++) {
nx = u;
ny = cul - v + 1;
u = nx;
v = ny;
}
for(int i = 1; i <= z; i++) {
nx = cul - v + 1;
ny = u;
u = nx;
v = ny;
swap(row, cul);
}
cout << u << " " << v << endl;
}
int main()
{
int x, y, z, p;
cin >> n >> m >> x >> y >> z >> p;
x %= 4; y %= 2; z %= 4;
for(int i = 0; i < p; i++) {
cin >> u >> v;
Solve(x, y, z);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: