I don't have a lot of experience with c++, but decided to give it a try since I heard it's very good for competitions. My code when used with an older compiler gives a wrong answer and with the new one the solution is correct, but it fails due to a runtime error in test 2. I couldn't find any issue in my code. Am I missing something?
You missing link to any code to watch at:)
I have a question.
whenever i write recursive lambda function. it does not work for long long. Like what if i need to return long long type in a dp problem.
for example:-
...
I don't want to write a blog for it that's why i asked here. Is there anyone who can tell the reason.
instead of
if(l>r)return 0;
try to do
if(l>r)return 0LL;
also all the return should have same return type so make sure they are all long long
You can also use the following
I was submitting my code for two sets(II) on cses. and it's giving runtime error. Can you tell me the reason. code
Edit:- maybe i am getting error because of something else.
The first dimension of your dp has size of $$$505$$$,
but you used it out of bound
Check out a famous blog https://codeforces.com/blog/entry/62393.
Thank you very much for this link. I've actually always thought when coding in java (my primary language) that HashMaps (or unordered_maps in this case) operations are always O(1).
Did you tried just with a regular map? Most of the time you don't need hashmaps