Codeforces 499B. Lecture Problem Solving Report

Source: Internet
Author: User

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

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.