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

题意:给出一个矩形的三种操作,顺时针旋转,逆时针旋转,对称,给出原始坐标,再给出操作数,问最后得到的坐标

画一下模拟一下操作就可以找到规律了

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include <cmath>
 5 #include<stack>
 6 #include<vector>
 7 #include<map>
 8 #include<set>
 9 #include<queue>
10 #include<algorithm>
11 using namespace std;
12
13 #define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
14
15 typedef long long LL;
16 const int INF = (1<<30)-1;
17 const int mod=1000000007;
18 const int maxn=100005;
19
20 int main(){
21     int N,M,x,y,z,p;
22     cin>>N>>M>>x>>y>>z>>p;
23     x=x%4;y=y%2;z=z%4;
24     while(p--){
25         int n,m;
26         n=N;m=M;
27         int u,v;
28         cin>>u>>v;
29         for(int i=0;i<x;i++){
30             swap(u,v);
31             swap(n,m);
32             v=m+1-v;
33         }
34         if(y) v=m+1-v;
35         for(int i=0;i<z;i++){
36             swap(u,v);
37             swap(n,m);
38             u=n+1-u;
39         }
40         printf("%d %d\n",u,v);
41     }
42     return 0;
43 }

大中午的做模拟---好醒觉啊

----- 加油---go000000000000000

时间: 2025-01-17 16:43:43

codeforces 400 C Inna and Huge Candy Matrix【模拟】的相关文章

codeforces C. Inna and Huge Candy Matrix

http://codeforces.com/problemset/problem/400/C 题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋转,z次逆时针反转,问最后每个糖果的位置. 思路:推出顺时针反转.旋转.逆时针反转的坐标的变化即可. 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <iostream>

二分查找/暴力 Codeforces Round #166 (Div. 2) B. Prime Matrix

题目传送门 1 /* 2 二分查找/暴力:先埃氏筛选预处理,然后暴力对于每一行每一列的不是素数的二分查找最近的素数,更新最小值 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <algorithm> 7 using namespace std; 8 9 const int MAXN = 5e2 + 10; 10 const int MAXM = 1e6 + 10; 11 const int INF = 0

Codeforces 216D Spider&#39;s Web 树状数组+模拟

题目链接:http://codeforces.com/problemset/problem/216/D 题意: 对于一个梯形区域,如果梯形左边的点数!=梯形右边的点数,那么这个梯形为红色,否则为绿色, 问: 给定的蜘蛛网中有多少个红色. 2个树状数组维护2个线段.然后暴力模拟一下,因为点数很多但需要用到的线段树只有3条,所以类似滚动数组的思想优化内存. #include<stdio.h> #include<iostream> #include<string.h> #in

Codeforces 439C Devu and Partitioning of the Array(模拟)

题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,但是只需要关注该份的和为奇数还是偶数,要求偶数堆的个数为p.输出方案. 解题思路:首先先将数组按照奇偶排序,也可以分开储存.然后先单独分k-p个奇数,然后后面的就将两个奇数当一个偶数分配,分配过程中计算是否满足,比如说奇数是否成对,以及是否分成了k堆. #include <cstdio> #include <cstring>

Codeforces 390E Inna and Large Sweet Matrix 树状数组改段求段

题目链接:点击打开链接 题意:给定n*m的二维平面 w个操作 1.0 (x1,y1) (x2,y2) value for i : x1 to x2 for j : y1 to y2 mp[i][j] += value; 2.1 (x1, y1) (x2 y2) ans1 = 纵坐标在 y1,y2间的总数 ans2 = 横坐标不在x1,x2间的总数 puts(ans1-ans2); 因为n最大是4e6, 所以用树状数组改段求段代替线段树 #include <stdio.h> #include &

CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)

树状数组只能实现线段树区间修改和区间查询的功能,可以代替不需要lazy tag的线段树,且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c); 1.单点修改 : c[x] += y; 对应的函数是 change(x, y); 2.求前缀和 :  对应的函数是 int sum(x) 两种操作的复杂度都是O(logn) 模板如下: int c[N], maxn; inline int Lowbit(int x){return x&(-x);}

Codeforces Round #531 (Div. 3) F. Elongated Matrix(状压DP)

F. Elongated Matrix 题目链接:https://codeforces.com/contest/1102/problem/F 题意: 给出一个n*m的矩阵,现在可以随意交换任意的两行,最后从上到下,从左到右形成一个序列s1,s2.....snm,满足对于任意相邻的两个数,它们差的绝对值的最大值为k. 现在问怎么交换行与行,可以使得最后的这个k最大. 题解: 人生中第一道状压dp~其实还是参考了这篇博客:https://blog.csdn.net/CSDNjiangshan/art

Codeforces Round #540 (Div. 3) C. Palindromic Matrix 【暴力】

任意门:http://codeforces.com/contest/1118/problem/C C. Palindromic Matrix time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's call some square matrix with integer values in its cells palind

Codeforces Round #277 (Div. 2) B.OR in Matrix 模拟

B. OR in Matrix Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or