Poj2503--babelfish (Terry one water)

Source: Internet
Author: User

Babelfish
Time Limit: 3000MS Memory Limit: 65536K
Total Submissions: 32988 Accepted: 14189

Description

You are just moved from Waterloo to a big city. The people speak an incomprehensible dialect of a foreign language. Fortunately, you had a dictionary to help you understand them.

Input

Input consists of 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words . Each dictionary entry are a line containing an 中文版 word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language and one word on each line. Each word in the input is a sequence of lowercase letters.

Output

Output is the message translated to 中文版, one word per line. Foreign words not in the dictionary should is translated as "eh".

Sample Input

Dog Ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Sample Output

Catehloops

Hint

Huge input and output,scanf and printf are recommended.

Source

Waterloo local 2001.09.22 Enter a dictionary. The previous word and the following word map. Ask the given word there is no corresponding, there is output, no, output eh
#include <cstdio> #include <cstring> #include <algorithm>using namespace std;struct node{int flag; Node *next[27];}    *head;node *getnode () {Node *p = new node;    int i;    for (i = 0; i <; i++) p->next[i] = NULL;    P->flag =-1; return p;}    void Gettree (node *p,char *s,int m) {int i, k, L = strlen (s);        for (i = 0; i < L; i++) {k = s[i]-' a ';        if (p->next[k] = = NULL) P->next[k] = GetNode ();    p = p->next[k]; } P->flag = m;}    int f (node *p,char *s) {int i, k, L = strlen (s);        for (i = 0; i < L; i++) {k = s[i]-' a ';        if (p->next[k] = = NULL) return-1;    p = p->next[k]; } return P->flag;}    Char s1[110000][12], s2[110000][12], s[30]; int main () {int i = 0, J, l, K;    Head = GetNode ();        while (1) {gets (s);        if (s[0] = = ' + ') break;     SSCANF (S, "%s%s", S1[i], s2[i]);   Gettree (Head,s2[i],i);    i++;        } while (gets (s)!=null) {if (s[0] = = ' + ') break;        K = f (head,s);        if (k = =-1) printf ("eh\n");    else printf ("%s\n", S1[k]); } return 0;}

Copyright NOTICE: Reprint Please specify source: Http://blog.csdn.net/winddreams

Poj2503--babelfish (Terry one water)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.