Fume's blog

By Fume, history, 7 months ago, In English

I am trying to reduce the calls to access map elements so used varaibles by reference but got runtime error. Can anyone help. Runs correctly on local machine.

https://mirror.codeforces.com/contest/1974/submission/262484871

  • Vote: I like it
  • -3
  • Vote: I do not like it

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

how will this even reduce the number of calls it still takes O(N) time

»
7 months ago, # |
  Vote: I like it +3 Vote: I do not like it

You do not need references but if you want to, then you have to maintain their validness (learn about rebalancing of maps). Also you should not try to deallocate memory that maps alloced internally (this leads to the runtime errors I think).