Codeforces 669C Little Artem and Matrix (模拟)
来源:互联网 发布:蒙古表情 软件 编辑:程序博客网 时间:2024/04/30 00:44
题意
对一个矩阵有三种操作
1.第row行循环右移x位
2.第col列循环下移x位
3.告诉你第row行的第col列的数是x。
要求构造出符合操作的原矩阵。
思路
因为数据很小,直接暴力就可以了,按照操作倒着模拟一遍,有3操作的就填数,没有的就为0。
代码
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define LL long long#define Lowbit(x) ((x)&(-x))#define lson l, mid, rt << 1#define rson mid + 1, r, rt << 1|1#define MP(a, b) make_pair(a, b)const int INF = 0x3f3f3f3f;const int MOD = 1000000007;const int maxn = 1e5 + 10;const double eps = 1e-8;const double PI = acos(-1.0);typedef pair<int, int> pii;int a[110][110];struct node{ int type; int r, c, x;}p[10010];int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); memset(a, 0, sizeof(a)); int n, m, q; scanf("%d%d%d", &n, &m, &q); for (int i = 0; i < q; i++) { int t; scanf("%d", &t); if (t == 3) { p[i].type = 3; scanf("%d%d%d", &p[i].r, &p[i].c, &p[i].x); } if (t == 2) { p[i].type = 2; scanf("%d", &p[i].c); } if (t == 1) { p[i].type = 1; scanf("%d", &p[i].r); } } for (int i = q - 1; i >= 0; i--) { if (p[i].type == 1) { int row = p[i].r; int t = a[row][m]; for (int i = m; i >= 2; i--) a[row][i] = a[row][i-1]; a[row][1] = t; } if (p[i].type == 2) { int col = p[i].c; int t = a[n][col]; for (int i = n; i >= 2; i--) a[i][col] = a[i-1][col]; a[1][col] = t; } if (p[i].type == 3) { a[p[i].r][p[i].c] = p[i].x; } } for (int i = 1; i <= n; i++, printf("\n")) for (int j = 1; j <= m; j++) printf("%d ", a[i][j]); return 0;}
0 0
- Codeforces #669 Div2 C. Little Artem and Matrix(模拟)
- Codeforces 669C Little Artem and Matrix (模拟)
- codeforces 669C Little Artem and Matrix
- codeforces#348-C. Little Artem and Matrix-模拟
- CodeForces 669C Little Artem and Matrix(暴力)
- Codeforces 669C Little Artem and Matrix【思维+暴力】
- Codeforces Round #348 (div 2) C. Little Artem and Matrix
- CodeForces 641C Little Artem and Dance (模拟)
- CodeForces 668A Little Artem and Matrix
- Codeforces 669B Little Artem and Grasshopper【思维+模拟】
- CodeForces 669A Little Artem and Presents
- CodeForces 669B Little Artem and Grasshopper
- CodeForces 669D Little Artem and Dance
- CodeForces 669D Little Artem and Dance
- CodeForces 669A Little Artem and Presents
- 【CodeForces】669A - Little Artem and Presents
- 【CodeForces】[669A]Little Artem and Presents
- CodeForces 669A Little Artem and Presents
- Openlayers2中聚类的动态实现
- iOS之AFNetworking
- HDU 2680
- iOS网络中下载文件之断点续传
- iOS中黄色文件夹和蓝色文件夹的区别
- Codeforces 669C Little Artem and Matrix (模拟)
- KNN
- java中常见的设计模式
- 唯爱小粽子:软件架构的典型组成部分-资源管理
- scala中call-by-name和call-by-value
- R语言学习二 数据类型
- LeetCode Candy
- 关于Samba的SELiunx配置
- 加密