CodeForces 669C Little Artem and Matrix GNU

Posted Fighting Heart

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 669C Little Artem and Matrix GNU相关的知识,希望对你有一定的参考价值。

模拟。

把操作记录一下,倒着复原回去。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-6;
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c=getchar(); x=0;
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) {x=x*10+c-0; c=getchar();}
}

const int maxn=110;
int n,m,q;
int ans[maxn][maxn];
int op[10010],r[10010],c[10010],v[10010];

int main()
{

    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&op[i]);
        if(op[i]==1) scanf("%d",&r[i]);
        else if(op[i]==2) scanf("%d",&c[i]);
        else scanf("%d%d%d",&r[i],&c[i],&v[i]);
    }

    for(int i=q;i>=1;i--)
    {
        if(op[i]==3) ans[r[i]][c[i]]=v[i];
        else if(op[i]==1)
        {
            for(int j=m;j>1;j--)
                swap(ans[r[i]][j],ans[r[i]][j-1]);
        }
        else
        {
            for(int j=n;j>1;j--)
                swap(ans[j][c[i]],ans[j-1][c[i]]);
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            printf("%d ",ans[i][j]);
        printf("\n");
    }
    return 0;
}

 

以上是关于CodeForces 669C Little Artem and Matrix GNU的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 220B - Little Elephant and Array 离线树状数组

[CodeForces-259C] Little Elephant and Bits

『题解』Codeforces220B Little Elephant and Array

Little Girl and Maximum XOR CodeForces - 276D

Little Girl and Maximum Sum CodeForces - 276C

CodeForces - 258D Little Elephant and Broken Sorting