Codeforces 400C Inna and Huge Candy Matrix(模拟)
来源:互联网 发布:sql rownum用法 编辑:程序博客网 时间:2024/04/28 00:51
题目链接:Codeforces 400C Inna and Huge Candy Matrix
题目大意:给出n,m,x,y,z和p,表示在一个n*m的矩阵上有p块糖果,给出p块糖果的坐标,然后将整个矩阵顺时针旋转x次,镜像翻转y次,逆时针旋转z次,然后按照顺序输出操作完后糖果的坐标。
解题思路:模拟,注意旋转完,n和m要交换,翻转不用,然后如果纯模拟肯定超时,很容易发现旋转4次等于没变,翻转2次也是没有变的。
#include <stdio.h>#include <string.h>const int N = 1e5+5;struct state {int xi, yi;}s[N];int n, m, x, y, z, p;void cw() {for (int i = 0; i < p; i++) {int r = s[i].yi;int l = n + 1 - s[i].xi;s[i].xi = r; s[i].yi = l;}int t = n;n = m; m = t;}void hr() {for (int i = 0; i < p; i++)s[i].yi = m + 1 - s[i].yi;}void ccw() {for (int i = 0; i < p; i++) {int r = m + 1 - s[i].yi;int l = s[i].xi;s[i].xi = r; s[i].yi = l;}int t = n;n = m; m = t;}int main () {scanf("%d%d%d%d%d%d", &n, &m, &x, &y, &z, &p);for (int i = 0; i < p; i++)scanf("%d%d", &s[i].xi, &s[i].yi);x %= 4;for (int i = 0; i < x; i++) cw();y %= 2;for (int i = 0; i < y; i++) hr();z %= 4;for (int i = 0; i < z; i++) ccw();for (int i = 0; i < p; i++)printf("%d %d\n", s[i].xi, s[i].yi);return 0;}
1 0
- Codeforces 400C Inna and Huge Candy Matrix(模拟)
- Codeforces 400C Inna and Huge Candy Matrix 【模拟】
- Codeforces 400B Inna and Huge Candy Matrix(模拟)
- Codeforces 400 C. Inna and Huge Candy Matrix
- codeforces 400C - Inna and Huge Candy Matrix
- Codeforces 400C Inna and Huge Candy Matrix
- codeforces 400C Inna and Huge Candy Matrix
- codeforces Inna and Huge Candy Matrix
- C. Inna and Huge Candy Matrix(cf)
- C - Inna and Huge Candy Matrix
- Codeforces 400 C. Inna and Huge Candy Matrix【 Codeforces Round #234 (Div. 2)】
- code forces 400C Inna and Huge Candy Matrix
- CF 400C - Inna and Huge Candy Matrix
- (CF)C. Inna and Huge Candy Matrix
- codeforces 400C - Inna and Huge Candy Matrix(耐心找规律,细节还是要注意的)
- codeforces#234_div2_C Inna and Huge Candy Matrix
- CodeForces 390C Inna and Candy Boxes
- codeforces 390c Inna and Candy Boxes
- 可变数组的数据添加
- 如何在myeclipse中导入jar包
- JS中比较的数值如何比较大小
- 磁盘损坏导致datanode异常结束
- jsp学生管理系统
- Codeforces 400C Inna and Huge Candy Matrix(模拟)
- 根据年月获取全月时间
- UISegmentedControl 分段控件-IOS开发
- Linux操作系统下编辑保存退出命令
- xcode 5 single view app start
- Android平台下RFID模块测试程序
- memcache开机自启动脚本
- SVN中trunk,branches,tags用法详解
- CDockablePane使用及实例