You are not logged in. Please login at www.codechef.com to post your questions!

×

Strange behaviour of std::map

Why does this submission pass while this one fails ?

The only difference in the codes is that in the correct submission I inserted in the map as

            m[s]=i+1;

while in the 2nd one I inserted as :

        m.insert(make_pair(s,i+1));

and similarly for finding the index in the correct submission I used

            B[i] = m[s];

and in the incorrect submission I used :

            B[i] = m.find(s)->S;

So what is the cause of WA ? It has made me curious since quite a few days :(
Thanks!

asked 09 Feb '16, 13:32

h1ashdr%40gon's gravatar image

3★h1ashdr@gon
2912320
accept rate: 10%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×61
×18
×12
×2
×1
×1

question asked: 09 Feb '16, 13:32

question was seen: 366 times

last updated: 09 Feb '16, 13:32