-
Title Description:
-
One of Harry Potter's compulsory courses at the school of Witchcraft and Wizardry is learning spells. 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, list 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 "@END @", which does not belong to the entry in the dictionary.
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:
-
the output of each test case is one line, the output enchantment corresponds to the function, or the function corresponding to the enchantments. 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] control the MOV Ement of one ' s Legs[serpensortia] shoot a snake out of the end of one's wand[lumos] light the wand[obliviate] the memory C Harm[expecto Patronum] Send a Patronus to the Dementors[accio] the summoning Charm@[email protected]4[lumos]the summoning Charm[arha]take me to the sky
-
Sample output:
-
Light the wandacciowhat?what?
#include <map>#include<cstring>#include<iostream>#include<stdlib.h>using namespacestd;intMain () {map<string,string>A; stringname,function,s; intL,r; while(Getline (cin,s) && s!="@[email protected]") {L=s.find ('['); R=s.find (']'); Name=S.SUBSTR (L +1, r-l-1); function=s.substr (r+2, S.size ()-R); A[name]=function; A[function]=name; } intN; CIN>>N; Getline (cin,s); //Take that carriage return,!!!!!. for(intI=0; i<n;i++) {getline (cin,s); if(s[0]='[') {s.erase (s.size ()-1,1); S.erase (0,1); } if(A.find (s) ==a.end ()) cout<<"What ?"<<Endl; Elsecout<<a[s]<<Endl; } return 0;}
1029. Magic Spell Dictionary