What could be the Test Case 3 for which my code is getting WA?
created
last reply
- 8
replies
- 720
views
- 2
users
- 3
likes
- 5
links
What could be the Test Case 3 for which my code is getting WA?
Thank You for your reply.
I have solved that issue and used multimap
As we know, map has a complexity of insertion and deletion is O(1) and binary search has a complexity of O(logn).
My code has a complexity of O(nlog(n)). Then why it is giving TLE ?
My solution: https://pastebin.ubuntu.com/p/TnV9f9HMqt/4
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
I have used it for faster input output though i’ve used scanf prinf. Link1
tFinish_idx.erase(it)
It is for erasing finish time from the multimap. Editing map’s index is not valid. So i erased it first then inserted it with new finishing time .
You are using both cin and scanf - so what effect does ios::sync_with_stdio(0) have on that? The answer is that n would get some very strange values, far larger than you might expect.
I know why you’re using tFinish_idx.erase(it), but you’re not answering the question - what may happen to the ITERATOR after using using it? See www.cplusplus.com/reference/map/multimap/erase/. Iterators, pointers and references referring to elements removed by the function are invalidated. The iterator is invalidated, but you still continue to use it.
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
How to Tackle Difficult Problems on SPOJ? | Online Judge System | 1 | 182 | Jun '24 |