zoukankan      html  css  js  c++  java
  • Girls' Day POJ 1677 模拟

    Girls' Day
    Time Limit: 1000MS   Memory Limit: 10000K
    Total Submissions: 3145   Accepted: 640

    Description

    On Girls' Day (Haven't heard about it? Well, you may ask the author for details...), we boys get together with girls in the class. On the occasion, every boy will make a wish for girls. Boys want to know about girls' responses to their wishes. 

    If a wish contains one or more girls' names, it is considered to be talking to them specifically. Otherwise it is talking to all the girls. A wish can simultaneously talk to several girls of course. 

    A girl would say 'oh' if the wish contains at most 9 words. 
    A girl would say 'xixi' if the wish contains at least 10 words and she hears the word 'beautiful', 'pretty' or 'lovely'. 
    A girl would say 'hehe' if the wish contains at least 10 words and she doesn't hear such words mentioned above. 

    It is confirmed that a wish will not contain all the girls? name. 

    Input

    The first line of the input contains two integers g and w (1 <= g <= 5, 1 <= w <= 30), the number of girls and the number of wishes respectively. The next g lines each contain a word in lowercase, representing the name of a girl. Then the next w lines each contain a string of letters and punctuations, namely the wish, which will contain at most 200 characters. 

    Each wish contains one or more sentences, and each sentence is terminated by a '!'. The first letter of each sentence is in uppercase, and other letters will be always in lowercase. No other characters apart from '!', spaces and letters will appear in the sentence. You may assume that each wish is correct in grammar. 

    Output

    You are required to give girls' response according to the input. For each wish, if it is talking to all the girls, print 'All', or otherwise print the list of girls that it is talking to (names are separated by a single space) in the order that they appear in the name list. Then print a semicolon followed by a space, and the response such as 'hehe' and 'xixi'.

    Sample Input

    5 5
    answer
    baiqingr
    cedar
    juleo
    seven
    Happy girls day to all of you!
    Happy girls day to all of you!Wish you happy forever!
    Happy girls day for answer mm!
    Congratulations for cedar mm and seven mm!Wish you more and more beautiful hehe! 
    Hello answer hello baiqingr hello juleo would you mind having dinner together!
    

    Sample Output

    All: oh
    All: hehe
    answer: oh
    cedar seven: xixi
    answer baiqingr juleo: hehe
    

    Source

    /*
     * Author:  
     * Created Time:  2013/10/6 20:30:44
     * File Name: A.cpp
     * solve: A.cpp
     */
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cmath>
    #include<algorithm>
    #include<string>
    #include<map>
    #include<stack>
    #include<set>
    #include<iostream>
    #include<vector>
    #include<queue>
    //ios_base::sync_with_stdio(false);
    //#pragma comment(linker, "/STACK:1024000000,1024000000")
    
    using namespace std;
    #define sz(v) ((int)(v).size())
    #define rep(i, a, b) for (int i = (a); i < (b); ++i)
    #define repf(i, a, b) for (int i = (a); i <= (b); ++i)
    #define repd(i, a, b) for (int i = (a); i >= (b); --i)
    #define clr(x) memset(x,0,sizeof(x))
    #define clrs( x , y ) memset(x,y,sizeof(x))
    #define out(x) printf(#x" %d
    ", x)
    #define sqr(x) ((x) * (x))
    typedef long long LL;
    
    const int INF = 1000000000;
    const double eps = 1e-8;
    const int maxn = 100;
    
    int sgn(const double &x) {  return (x > eps) - (x < -eps); }
    
    string name[maxn];
    int used[maxn];
    struct fuck
    {
        string name;
        int id;
        
        bool operator < (const fuck& f)const
        {
            return id < f.id;
        }
    };
    vector<fuck> ans;
    
    char str[1000];
    char temp[300];
    string cmp[3] = {"beautiful","pretty","lovely"};
    int main() 
    {
        //freopen("in.txt","r",stdin);
        int n,w;
        scanf("%d%d",&n,&w);
        int Num = 0;
        rep(i,0,n)
        {
            string a;
            cin>>a;
            int tag = 0;
            rep(j,0,Num)
                if(name[j] == a)
                {
                    tag = 1;
                    break;
                }
            
            if(tag == 0)
            {
                name[Num] = a;
                Num++;
            }
        }
        getchar();
        repf(i,1,w)
        {
            ans.clear();
            int word = 0;
            int flag = 0;
            clr(used);
            gets(str);
            int len = strlen(str);
            str[len] = ' ';
            int cnt = 0;
            repf(j,0,len)
            {
                if(str[j] >= 'A' && str[j] <= 'Z')
                   str[j] += 'a' - 'A';
                if(str[j] == ' ' || str[j] == '!')
                {
                    temp[cnt] = '';
                    string Name = temp;
                    
                    rep(k,0,3)
                        if(cmp[k] == Name)
                            flag = 1;
                    
                    rep(k,0,Num)
                    {
                        if(used[k])
                            continue;
                        if(name[k] == Name)
                        {
                            used[k] = 1;
                            ans.push_back((fuck){Name,k});
                        }
                    }
                    cnt = 0;
                    continue;
                }
                temp[cnt] = str[j];
                cnt++;
            }
            repf(j,0,len-1)
            {
                if(str[j] >= 'a' && str[j] <= 'z')
                {
                    if(str[j+1] == ' ' || str[j+1] == '!')
                        word++;
                }
            }
            int num = 0;
            rep(i,0,n)
                if(used[i])
                    num++;
    
            if(num == 0)
                printf("All: ");
            else
            {
                sort(ans.begin(),ans.end());
                cout<<ans[0].name;
                rep(i,1,ans.size())
                    cout<<" "<<ans[i].name;
                cout<<": "; 
            }
    
            if(word <= 9)
            {
                printf("oh
    ");
                continue;
            }
          
            if(word >= 10 && flag)
            {
                printf("xixi
    ");
                continue;
            }
    
            if(word >= 10 && !flag)
            {
                printf("hehe
    ");
                continue;
            }
    
        }
        return 0;
    }
  • 相关阅读:
    zombie处理
    exec
    fork
    udp program
    PS中进程状态
    关闭socket连接最好的方法
    setsockopt
    【Python】Webpy 源码学习
    web.py 安装
    WSGI、flup、fastcgi、web.py的关系
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3355908.html
Copyright © 2011-2022 走看看