as I submitted my code to D (1 or 2, doesn't matter) it had TLE at test 2. https://codeforces.me/contest/1326/submission/73715713 I reshuffled the code and it passed. https://codeforces.me/contest/1326/submission/73724920 now the weird thing is that my original code passed test 2 when I ran it from home. any ideas why or what?
Reason: Line 469, you used the macro
Which, from line 23, is equivalent to
Which, from line 19, is equivalent to
Which, from line 17, is equivalent to
Since
extra.size()
is of typeunsigned int
, your code crashes when it is equal to0
.REAL reason: Your macro sucks massive huge enormous balls. Consider scrapping it for the sake of debuggability :-s
it was not true, as I told, the code passed correctly when I ran the same input on my computer. to be sure, I just put it in an online debugger — https://www.onlinegdb.com/ — and it took 0.25 seconds at the slow environment. definitely not 2 seconds
Well, it might be the case that
size_t
— the type ofvector::size()
is defined to beint
orlong long
on your machine. But I'm sure that it is unsigned on Codeforces. Your solution crashes when I run it on Codeforces Custom Invocation. The "TLE" verdict is becauseextra.size() - 1
is evaluated to be $$$2^{32} - 1$$$, not because of slow performance.Anyway, try to keep that in mind and remember to cast the type to
int
orlong long
to avoid those situations.