I was solving this question http://codeforces.net/problemset/problem/696/E and my code is passsing in less than a second int max test cases as in test case 10 but it is giving TLE in test case 14 where there is a single node.I am unable to find where it is getting TLE. someone please help and please do not down vote as i have been caught for a while. My submission: http://codeforces.net/contest/696/submission/19464350
It was erasing from vector which was creating problems on replacing it with deque it is now getting TLE on test 36 again a max case while in others max cases it is passing in a second .Please someone help submission: http://codeforces.net/contest/696/submission/19466125
GOT AC. Seemed the problem was in this line. I sorted the vector and the operation v.erase(v.begin()) was the cause of TLE. REplacing it with set and deque passed . Can someone explain the vector part.
erase in vector is O(N) "Linear on the number of elements erased (destructions) plus the number of elements after the last element deleted (moving)."
http://www.cplusplus.com/reference/vector/vector/erase/