problem:- https://mirror.codeforces.com/contest/1996/problem/C
I was solving the above problem using C++ vector of maps and i got memory limit exceeded. But I solved the same problem with the same logic using vectors of vector and got accepted solution .I am unable to understand why the solution using maps failed.
Solution using maps:- https://mirror.codeforces.com/contest/1996/submission/273021146
Solution using vectors of vector:- https://mirror.codeforces.com/contest/1996/submission/273020910
Can someone expalin?
Auto comment: topic has been updated by proAakash (previous revision, new revision, compare).
Auto comment: topic has been updated by proAakash (previous revision, new revision, compare).
Vector needs to store only the value for each element
Map needs to store key, value, color, pointers to left son, right son and parent for each element (and maybe even more, I am not sure)
So it's just usual MLE, map needs much more memory
thanks mate! now i got it.