codeforces C. Inna and Huge Candy Matrix
http://codeforces.com/problemset/problem/400/C
题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋转,z次逆时针反转,问最后每个糖果的位置。
思路:推出顺时针反转、旋转、逆时针反转的坐标的变化即可。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#define maxn 100010
#include <algorithm>
using namespace std; int n,m,x,y,z,k;
struct node
{
int x,y;
} p[maxn]; int main()
{
scanf("%d%d%d%d%d%d",&n,&m,&x,&y,&z,&k);
for(int i=; i<=k; i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
}
x%=;
y%=;
z%=;
for(int i=; i<=k; i++)
{
int nn=n,mm=m,xx,yy;
for(int j=; j<=x; j++)
{
xx=p[i].x;
yy=p[i].y;
p[i].x=yy;
p[i].y=nn-xx+;
swap(nn,mm);
}
for(int j=; j<=y; j++)
{
xx=p[i].x;
yy=p[i].y;
p[i].x=xx;
p[i].y=mm-yy+;
}
for(int j=; j<=z; j++)
{
xx=p[i].x;
yy=p[i].y;
p[i].x=mm-yy+;
p[i].y=xx;
swap(nn,mm);
}
}
for(int i=; i<=k; i++)
{
printf("%d %d\n",p[i].x,p[i].y);
}
return ;
}
codeforces C. Inna and Huge Candy Matrix的更多相关文章
- codeforces C. Inna and Huge Candy Matrix 解题报告
题目链接:http://codeforces.com/problemset/problem/400/C 题目意思:给出一个n行m列的矩阵,问经过 x 次clockwise,y 次 horizontal ...
- codeforces round #234B(DIV2) C Inna and Huge Candy Matrix
#include <iostream> #include <vector> #include <algorithm> #include <utility> ...
- codeforces 400 C Inna and Huge Candy Matrix【模拟】
题意:给出一个矩形的三种操作,顺时针旋转,逆时针旋转,对称,给出原始坐标,再给出操作数,问最后得到的坐标 画一下模拟一下操作就可以找到规律了 #include<iostream> #inc ...
- codeforces 390E Inna and Large Sweet Matrix
本题的主要算法就是区间更新和区间求和: 可以用线段树和树状数组来做: 感觉线段树写的太麻烦了,看到官方题解上说可以用树状数组做,觉得很神奇,以前用过的树状数组都是单点维护,区间求和的: 其实树状数组还 ...
- CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)
树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c) ...
- Codeforces 390E Inna and Large Sweet Matrix 树状数组改段求段
题目链接:点击打开链接 题意:给定n*m的二维平面 w个操作 int mp[n][m] = { 0 }; 1.0 (x1,y1) (x2,y2) value for i : x1 to x2 for ...
- codeforces 390D Inna and Sweet Matrix
几个小结论: 1.路径长度=i+j-1; 2.最简单的走法是先横走再竖着走或者先竖着走再横着走 #include<cstdio> #include<cstring> using ...
- codeforces 390C Inna and Candy Boxes
这个题目看似不是很好下手,不过很容易发现每次询问的时候总是会问到第r个盒子是否有糖果: 这样的话就很好办事了: 维护两个数组: 一个sum数组:累加和: 一个in数组:如果i位是1的话,in[i]=i ...
- codeforces 374A Inna and Pink Pony 解题报告
题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行 m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...
随机推荐
- Jenkins的plugin开发
Jenkins强大的功能主要靠其丰富的plugin体现,之前的一篇博客<Jenkins安装plugin>中介绍了如何找到并安装需要的plugin.虽然目前已经有大量非常优秀的plugin可 ...
- hdu 3729 I'm Telling the Truth 二分图匹配
裸的二分图匹配.需要输出方案. #include<cstdio> #include<cstring> #include<vector> #include<al ...
- [AngularJS] Accessing The View-Model Inside The link() When Using controllerAs
If u using controller & controllerAs in directive, then the link()'s 4th param 'controller' will ...
- /proc/sys/ 下内核参数解析
http://blog.itpub.net/15480802/viewspace-753819/ http://blog.itpub.net/15480802/viewspace-753757/ ht ...
- 关于jsp web项目中的javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver错误
错误: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver org.apache.j ...
- 在Linux下用netstat查看网络状态、端口状态
在Linux下用netstat查看网络状态.端口状态 在linux一般使用netstat 来查看系统端口使用情况步. netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表.实 ...
- ajax跨域传值
<script type="text/javascript"> function xmlpage(){ $.ajax({ url:'http://localhost/3 ...
- Javascript基础(2)
开始更咯~~~嘻嘻. ---------------------------------------------------------------------------------- 异常捕获:即 ...
- hdoj 2047 简单递推
代码: #include <stdio.h>int main(){ int n,m,i; __int64 x[41]; x[1]=3; x[2]=8; for(i=3;i<=40;i ...
- hibernate映射关系之多对多
多对多: * 关系在第三张表中,和两张表本身没有关系 * 多对多谁维护关系:谁都能维护关系(效率是一样的),一般情况下可以通过页面 来体现 * 关系体现: 第三张表的维护:增加.删除 course类对 ...