C + + Road Advanced--hdu1880 (Magic Spell dictionary)

Source: Internet
Author: User
Tags silver light

---restore content starts---

new~ Welcome to participate in more than 2016 school joint training Students ~
Magic Spell DictionaryTime limit:8000/5000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 12371 Accepted Submission (s): 3019


Problem description Harry Potter one of the compulsory courses in the wizarding school is to learn the curse. It is said that there are 100000 different enchantments in the Wizarding world, and it is difficult for Harry to remember it all, but in order to fight the enemy, he must be able to invoke any desired spell in a critical moment, so he needs your help.

Give you a spell dictionary. When Harry hears a spell, your program must tell him the function of the spell, and when Harry needs a function but does not know what spell to use, your program will find the appropriate spell for him. If the spell he wants is not in the dictionary, the output is "what?"
Input first lists no more than 100,000 different spell entries in the dictionary, each in the following format:

[Magic Spell] corresponding function

where "enchantments" and "corresponding functions" are strings that do not exceed 20 and 80 in length, the string guarantees that the characters "[" and "]" are not included, and that there is only one space between the "]" and the subsequent strings. The last line of the dictionary ends with "@[email protected", which does not belong to the dictionary entry.
The line after the dictionary contains a positive integer n (<=1000) followed by n test cases. Each test case takes on one line, or "[enchantments]", or "corresponding function".
Output for each test case is one row, the output enchantment corresponds to the function, or the function corresponding to the enchantment. If the spell is not in the dictionary, output "what?"
Sample Input[expelliarmus] The disarming Charm[rictusempra] send a jet of silver light-to-hit the Enemy[tarantallegra] Con Trol the movement of one ' s Legs[serpensortia] shoot a snake out of the end of one's wand[lumos] light the wand[obliviate] The memory Charm[expecto Patronum] Send a Patronus to the Dementors[accio] the summoning Charm@[email protected]4[lumos]th E Summoning charm[arha]take me to the sky
Sample outputlight the Wandacciowhat?what?
Authorzju
SOURCE Zhejiang University Computer Postgraduate exam on the machine-2008

Exercises

Bare hash, nothing to say ... Incidentally, the data is too water ... Violence all over ... Big data included, file hxyzc./cpp/pas/c

Data address: Http://pan.baidu.com/s/1geTcwXt, extract password: hyxzc

1#include <iostream>2#include <cstdio>3#include <cstring>4 #defineMAXN 1000105 using namespacestd;6 stringss,sss;7 Chars[1010];8 Chars1[maxn][ -],s2[maxn][ -];9 intN,TOT,L1[MAXN],L2[MAXN];Ten intMain () One { A     inti,j,k; -Freopen ("hyxzc.in","R", stdin); -Freopen ("Hyxzc.out","W", stdout); the      while(1) -     { - gets (s); -         if(s[0]=='@') Break; +tot++; -         intL=strlen (s); +          for(i=0; i<=l-1; i++) A         { ats1[tot][l1[tot]++]=S[i]; -             if(s[i]==']') Break; -         } -          for(j=i+2; j<=l-1; j + +) -s2[tot][l2[tot]++]=S[j]; -     } inCin>>N; -     CharC=GetChar (); to      while(n--) +     { - gets (s); the         intL=strlen (s); *ss=s; $         if(ss[0]=='[')Panax Notoginseng         { -              for(i=1; i<=tot;i++) the             { +sss=S1[i]; A                 if(ss==SSS) the                 { +cout<<s2[i]<<Endl; -                      Break; $                 } $             } -             if(i==tot+1) -cout<<"What ?"<<Endl; the         } -         ElseWuyi         { the              for(i=1; i<=tot;i++) -             { Wusss=S2[i]; -                 if(ss==SSS) About                 { $                      for(j=1; j<l1[i]-1; j + +) -cout<<S1[i][j]; -cout<<Endl; -                      Break; A                 } +             } the             if(i==tot+1) -cout<<"What ?"<<Endl; $         } the     } the     return 0; the}

C + + Road Advanced--hdu1880 (Magic Spell dictionary)

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.