On the weekend I will attend a programing competition and I would like to know whether should I use std::vector or std::map? I would use them simply as arrays but I am confused which is the better(mostly speed for basic operations)?
I saw this pic on stackoverflow and I have no idea which is the main difference between these…

The picture suggest that vector is faster…
I really don’t know what to do pls help me! I need to use them only like arrays but with dynamical size…
Thanks in advance,
EDIT
I will probably get a 2D array of integers (for example a map of a city or a labirinth and I would be given some kind of problem that could be solved with graph-algorithms or dynamic programming), so the things I will need are: write, read specific cells of the “table”, search for specific values, and I guess thats all.
I heard that std::map won’t locate the full N*M sized table in the memory, but I will do it value by value… So is it true that it may use less memory?
Sorry for being so silly but I have never had any real teachers I learned all that I know on my on. I just started to learn about data structures(2-3 trees, red-black trees, binomial heaps, and so on…)
That completely depends on what you want/need to do. If you need to input 2 numbers from the user, add them and the display the result, there’s no point in using a vector or a map.
However, if you need to store an array of objects (or primitives),
std::vectoris generally the way to go. If you need storage of keys and values, then that’s whatstd::maphas been invented for. The question you asked is way too broad, so it’s practically very hard to answer it, but you may still get the idea.Also, you can get some inspiration about code that you should never try to replicate here.