hnu 13052 What does the fox say?

What does the fox say?
Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:65536KB
Total submit users: 17, Accepted users: 17
Problem 13052 : No special judgement
Problem description
Determined to discover the ancient mystery ? the sound that the fox makes ? you went intothe forest, armed with a very good digital audio recorder. The forest is, however, full of animals’voices, and on your recording, many different sounds can be heard. But you are well preparedfor your task: you know exactly all the sounds which other animals make. Therefore the rest ofthe recording ? all the unidentified noises ? must have been made by the fox.

Input
The first line of input contains the number of test cases T. The descriptions of the test casesfollow:
The first line of each test case contains the recording ? words over lower case English alphabet,separated by spaces. Each contains at most 100 letters and there are no more than 100 words. Thenext few lines are your pre-gathered information about other animals, in the format < animal >goes < sound >. There are no more than 100 animals, their names are not longer than 100letters each and are actual names of animals in English. There is no fox goes ... among theselines.
The last line of the test case is exactly the question you are supposed to answer: what doesthe fox say?

Output
For each test case, output one line containing the sounds made by the fox, in the order fromthe recording. You may assume that the fox was not silent (contrary to popular belief, foxes donot communicate by Morse code).

Sample Input
1
toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot
dog goes woof
fish goes blub
elephant goes toot
seal goes ow
what does the fox say?
Sample Output
wa pa pa pa pa pa pow

简直心累。。。。一个字符串的处理。。。搞了老半天。。

在这上面吃了好多亏了。。。都瞎了!!!!

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <string>

#define eps 1e-8
#define op operator
#define MOD  10009
#define MAXN  100100
#define INF 0x7fffffff

#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define FOV(i,a,b)  for(int i=a;i>=b;i--)
#define REP(i,a,b)  for(int i=a;i<b;i++)
#define REV(i,a,b)  for(int i=a-1;i>=b;i--)
#define MEM(a,x)    memset(a,x,sizeof a)
#define ll __int64

using namespace std;

char ch[20000];
char voice[110][110];
char ani[1200];
char say[1200][1200];
char go[1200];
char word[1200];

int main()
{
//freopen("b.txt","r",stdin);
    int tc;
    scanf("%d",&tc);
    getchar();
    while(tc--)
    {
//    cout<<tc<<endl;
         char r;
         r=getchar();
         int x=0;
         int num=0;
//        cout<<"rrr  "<<r<<endl;
         while(r!='\n')
         {
//        cout<<"111"<<endl;
             if(r!=' ')
                voice[num][x++]=r;
             else
             {
                 voice[num][x]='\0';
                 num++;
                 x=0;
             }
             r=getchar();
         }
         voice[num][x]='\0';
//         for(int i=0;i<=num;i++)
//            cout<<voice[i]<<"   ";
//        cout<<endl;
         int flag=0;
         int cnt=0;
            while(1)
            {
                scanf("%s",ani);
                scanf("%s",go);
                scanf("%s",say[cnt]);
                if(strcmp(go,"does")==0)
                {

                    break;
                }
                else
                {
                    cnt++;
                }
            }
            gets(word);//把这里改了  之前是用scanf 读取两个字符串
//            for(int i=0;i<cnt;i++)
//                cout<<say[i]<<"  ";
//            cout<<endl;
            for(int i=0;i<=num;i++)
            {
                int j;
                for(j=0;j<cnt;j++)
                {
                    if(strcmp(voice[i],say[j])==0)
                        break;
                }
                if(j==cnt)
                {
                    if(flag)
                    {
                        printf(" %s",voice[i]);
                    }
                    else
                    {
                        printf("%s",voice[i]);
                        flag=1;
                    }
                }
            }
            cout<<endl;
    }
    return 0;
}



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值