I’m trying too much to optimize my code for problem MSV , but it was TLE .
At last AC , when I used register
keyword before (frequently used) variable.
Hope, this topics may help beginners like me.
Here is the submission link:
TLE 20 pts
AC 100 pts
EDIT:
After changing map with gp_hash_table , it takes only 0.24 sec::
Updated Submission
Try using an array instead of map. It should work.
1 Like
Oh yes , that can save few seconds. Thanks.
s5960r
October 14, 2019, 4:00pm
4
Or simply change it to unordered_map
1 Like
I know that, But I’m too confused about using unordered_map. A solution was accepted when I used map but TLE when i used unordered_map .
Using Unordered_map :: TLE 2000ms+
Using map :: AC 342 ms
[ Just declaration is the difference between AC and TLE code ]
Would be appreciated if you look out and help.
smile_forever:
I know that, But I’m too confused about using unordered_map. A solution was accepted when I used map but TLE when i used unordered_map .
Using Unordered_map :: TLE 2000ms+
Using map :: AC 342 ms
[ Just declaration is the difference between AC and TLE code ]
Would be appreciated if you look out and help.
Can you please explain it?
That’s because unordered map have worst time complexity on O(n).
Check this:
2 Likes
Thanks for clarification.
s5960r
October 14, 2019, 4:45pm
9
That’s true ! However unordered_map worked for this one
1 Like
Yes, unordered map worked for this. But I found gp_hash_table
faster than unordered_map
. Here is the updated solution which take only 0.24 sec.
1 Like