areke's blog

By areke, history, 8 years ago, In English

Hi everyone!

I'm having trouble with my submission for problem 382A.

The lines in question are commented in the submission above, but I'll highlight them here as well for clarity.

Using the following passes all the test cases:

    long long len = w2.length();
    len -= w1.length();
    len = absol(len-1);

While using this instead fails the first one, but returns the correct answer on my local machine:

    long long len = absol(w2.length()- w1.length()-1);

Does anyone have an idea of what's going on at a technical level?

My best guess is that it has something to do with precedence, and that in the second case the function address is being returned instead of the actual length. I'm not sure if this is the problem though and I've never run into something like this before.

I've tried doing a bunch of research on this issue, but haven't yet been able to find the answer. I'm hoping the great Codeforces community can help me out!

Thank you guys in advance!

Full text and comments »

Tags c++
  • Vote: I like it
  • -3
  • Vote: I do not like it