zoukankan      html  css  js  c++  java
  • 魔咒词典--hdu1880(字符串 暴力)

    http://acm.hdu.edu.cn/showproblem.php?pid=1880

    不要想其他的   暴力就能过

    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <cstdio>
    #include <cstdlib>
    #include <math.h>
    #include <ctype.h>
    
    using namespace std;
    #define memset(a,b) memset(a,b,sizeof(a))
    #define N 200
    #define INF 0xfffffff
    typedef long long  ll;
    
    char ch1[101000][25],ch2[101000][85];
    
    int main()
    {
        char str[N];
    
        int k=0;
        memset(ch1,0);
        memset(ch2,0);
        memset(str,0);
        while(1)
        {
            gets(str);
            if(strcmp(str,"@END@")==0)
                break;
            int f=0;
            int a,b;
            a=b=0;
            for(int i=0; str[i]; i++)
            {
                if(f==0)
                {
                    ch1[k][a++]=str[i];
                }
                if(f==1)
                {
                    ch2[k][b++]=str[i];
                }
                if(str[i]==']')
                {
                    f=1;
                    i++;
                }
            }
            k++;
        }
        int m;
        scanf("%d ",&m);
       char ch[N];
        while(m--)
        {
            memset(ch,0);
            int flag=0;
            gets(ch);
            if(ch[0]=='[')
            {
                for(int i=0; i<k; i++)
                {
                    if(strcmp(ch,ch1[i])==0)
                    {
                        printf("%s
    ",ch2[i]);
                        flag=1;
                        break;
                    }
                }
            }
            else
            {
                for(int i=0; i<k; i++)
                {
                    if(strcmp(ch2[i],ch)==0)
                    {
                        int l=strlen(ch1[i]);
                        for(int j=1;j<l-1;j++)
                            printf("%c",ch1[i][j]);
                        printf("
    ");
                        flag=1;
                        break;
                    }
                }
            }
            if(flag==0)
                printf("what?
    ");
        }
        return 0;
    }
  • 相关阅读:
    CSS性能让JavaScript变慢?
    Cordova优缺点与环境部署
    nodeapi
    git常用命令
    常见状态码
    关于拉萨
    英语学习
    SQL 按表中的一个int值拆分成对应的个数的记录条数
    SQL分组编号
    C#四舍五入
  • 原文地址:https://www.cnblogs.com/linliu/p/5398572.html
Copyright © 2011-2022 走看看