题目链接: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;
}
分享到:
相关推荐
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
打codeforces的神器
codeforces编程网站预测分数插件
CF gym模拟赛CF gym模拟赛CF gym模拟赛CF gym模拟赛
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
暴枚最长桌脚的长度$l$,然后长度比$l$长的桌脚全部都要砍掉长度比$l$短的桌脚选择代价前$k$小的砍掉用线段树维护;示例程序 :typedef long l
Codeforces 185A - Plant 全测试点49个
Codeforces 1105B - Zuhair and Strings 测试点37个(全)
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces-177A1-良好矩阵元素 链接: :
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
Some of the Codeforces problems codes
用于模拟Codeforces Javascript IO功能的小包装。 安装 npm i @ip-algorithmics/codeforces-io 介绍 Javascript / Typescript的Codeforce使用readLine()和print()函数输入和输出到标准输入/控制台。 如何使用 该库...
一个Codeforces、牛客竞赛、AtCoder平台的编程竞赛查询插件,ACMer必备.zip
Codeforces round 678 D2_Codeforces_源码
因为E题卡了半个小时最后还没解决掉,还剩十分钟结束比赛的时候看到群友说F题是模拟,抓紧时间去读题,读完题后感觉还算蛮简单的,稍微写了写调了一下,补题的时候交上去直接就A了,有种上当了的感觉 因为两种操作...
codeforces-js Codeforces JS
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done