zoukankan      html  css  js  c++  java
  • POJ 3106 Flip and Turn 模拟 分析

    --------

    const int maxn=400;
    const int maxm=200000;
    int n,m;
    char a[maxn][maxn];
    char b[maxn][maxn];
    int stk[10];
    int cnt;
    char s[maxm];
    char cd[7][3]={"1","CX","V","BY","2","AZ","H"};
    char sp[7][8]={"1","1H","1H1","1H1H","1H1H1","1H1H1H","H"};
    void work(char cmd){
        for (int i=1;i<=n;i++){
            for (int j=1;j<=m;j++){
                if (cmd=='1') b[j][i]=a[i][j];
                if (cmd=='H') b[n-i+1][j]=a[i][j];
            }
        }
        if (cmd=='1') swap(n,m);
        for (int i=1;i<=n;i++){
            for (int j=1;j<=m;j++){
                a[i][j]=b[i][j];
            }
        }
    }
    void stkPush(char cmd){
        for (int i=0;i<7;i++){
            if (strchr(cd[i],cmd)!=NULL){
                int len=strlen(sp[i]);
                for (int j=0;j<len;j++){
                    if (cnt>0&&stk[cnt-1]==sp[i][j]) cnt--;
                    else stk[cnt++]=sp[i][j];
                    if (cnt>=8) cnt=0;
                }
                break;
            }
        }
    }
    int main(){
        while (~scanf("%d%d",&n,&m)){
            cnt=0;
            for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
            scanf("%s",s);
            int len=strlen(s);
            for (int i=0;i<len;i++) stkPush(s[i]);
            for (int i=0;i<cnt;i++) work(stk[i]);
            printf("%d %d
    ",n,m);
            for (int i=1;i<=n;i++){
                for (int j=1;j<=m;j++){
                    printf("%c",a[i][j]);
                }
                printf("
    ");
            }
        }
    	return 0;
    }


    --------

  • 相关阅读:
    12. nc/netcat 用法举例
    7. 由一道ctf学习变量覆盖漏洞
    11. 几点基于Web日志的Webshell检测思路
    约瑟夫环
    栈结构的经典算法题
    二叉查找树之二
    fork与vfork
    数组常见算法题
    赛马问题
    fibonacci 数列及其应用
  • 原文地址:https://www.cnblogs.com/cyendra/p/3681529.html
Copyright © 2011-2022 走看看