Title Link: Http://codeforces.com/problemset/problem/499/B
Title meaning: gives one by one correspondence of the M-Word table (word1, Word2) in two languages, and the N-words of professor's lecture. Ask what notes are written down. For a word of Professor ' s lecture, if found in the word list, word1, Word2 is possible. If the length of the Word1 <= Word2, the output word1, otherwise word2
Test map<string, string> usage, this I refer to the previous in Zoj do a question 1109 Language of fatmouse, leaf out, just the last to compare size (), the last unnecessary Baidu spent a long time, The key did not find the required = =, there are those key and value location, the most tragic is that a little bit of debugging, too late in the virtual submission .... The pain of life = =
1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <map>6 using namespacestd;7 8 stringvalue, key;9Map <string,string>MSS;Tenmap<string,string>:: Iterator loc; One A intMain () - { - #ifndef Online_judge theFreopen ("In.txt","R", stdin); - #endif //Online_judge - - intN, M; + while(SCANF ("%d%d", &n, &m)! =EOF) - { +Mss.clear ();//Finally, to add this thing too late to pay A for(inti =0; I < m; i++) at { -CIN >> Value >>key; -Mss[value] =key; - } - for(inti =0; I < n; i++) - { inCIN >>value; -LOC =Mss.find (value); to //if (loc! = Mss.end ())//This is for rigorous, in fact, can be found in the word list + // { - stringS1 =Mss[value]; the stringS2 = loc->First ; * if(S2.size () <=s1.size ()) $cout << S2 <<" ";Panax Notoginseng Else -cout << S1 <<" "; the // } + } APuts""); the } + return 0; -}
Codeforces 499B. Lecture Problem Solving Report