Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main.cpp : Defines the entry point for the console application.
- //
- #include "stdio.h";
- //#include "stdafx.h";
- #include <vector>;
- #define pb push_back
- #define pf push_front
- #define mp make_pair
- #define sz size
- #define ll long long
- #define ld long double
- #define fs first
- #define sc second
- #define forn(i, f, t) for(int i = f; i < t; i++)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- const int INF = 2147483647;
- const int MOD = 1000000007;
- const ll INF64 = 9223372036854775807;
- const ld EPS = 1e-7;
- using namespace std;
- int main()
- {
- int n, m, q, x, y, val, pos, t;
- scanf("%d%d%d", &n, &m, &q);
- swap(n, m);
- vector<pair<pair<int, int>, pair<int, int> > > qs;
- vector<int> qt;
- forn(i, 0, q){
- scanf("%d", &t);
- x = -1, y = -1, pos = -1, val = -1;
- if (t <= 2) scanf("%d", &pos);
- else scanf("%d%d%d", &y, &x, &val);
- qt.pb(t);
- qs.pb(mp(mp(x - 1, y - 1),mp(val, pos - 1)));
- }
- // reverse(all(qs));
- // reverse(all(qt));
- int ans[101][101];
- int str[101];
- forn(i, 0, n) forn(j, 0, m) ans[i][j] = 0;
- forn(i, 0, q){
- if (qt[i] == 2){
- t = ans[0][qs[i].sc.sc];
- forn(j, 0, n - 1) ans[j][qs[i].sc.sc] = ans[j + 1][qs[i].sc.sc];
- ans[n - 1][qs[i].sc.sc] = t;
- }
- else if (qt[i] == 1){
- t = ans[qs[i].sc.sc][0];
- forn(j, 0, m - 1) ans[qs[i].sc.sc][j] = ans[qs[i].sc.sc][j + 1];
- ans[qs[i].sc.sc][m - 1] = t;
- }
- else
- ans[qs[i].fs.sc][qs[i].fs.fs] = qs[i].sc.fs;
- }
- reverse(all(qs));
- reverse(all(qt));
- //forn(i, 0, n){
- // forn(j, 0, m)
- // printf("%d ", ans[i][j]);
- // printf("\n");
- //}
- forn(i, 0, q)
- if (qt[i] == 2){
- t = ans[n - 1][qs[i].sc.sc];
- for (int j = n - 1; j > 0; j--) ans[j][qs[i].sc.sc] = ans[j - 1][qs[i].sc.sc];
- ans[0][qs[i].sc.sc] = t;
- }
- else if (qt[i] == 1){
- t = ans[qs[i].sc.sc][m - 1];
- for (int j = m - 1; j > 0; j--) ans[qs[i].sc.sc][j] = ans[qs[i].sc.sc][j - 1];
- ans[qs[i].sc.sc][0] = t;
- }
- forn(i, 0, n){
- forn(j, 0, m)
- printf("%d ", ans[i][j]);
- printf("\n");
- }
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement