WayBig's blog

By WayBig, history, 11 months ago, In English

In today's ABC305, I used multisource BFS to solve problem E. But it is giving TLE. Can anyone please point out the mistake? Moreover, an almost similar question also happened to appear in Codechef STARTERS 93. And an almost similar code, written by me, got accepted in it.

Problem Link: https://atcoder.jp/contests/abc305/tasks/abc305_e

Solution Link: https://atcoder.jp/contests/abc305/submissions/42175490

Code

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By WayBig, history, 11 months ago, In English

Dear Codeforces,

I wonder why there are so much fewer contests in the upcoming 1 month. Earlier, Codeforces used to have at least 2 contests per week but I see there are hardly 3 contests in the next 1 month. Is the contest page not updated or there's some other issue or there's actually not many contests coming up?

Please reply if there's some issue. MikeMirzayanov

Thank you.

Full text and comments »

  • Vote: I like it
  • -20
  • Vote: I do not like it

By WayBig, history, 12 months ago, In English

I am facing Time Limit Exceeded in the problem Coin Combinations II of cses.

Code:

Full code

My approach: We define rec(x, r) as the number of ordered ways to make a sum x by using up to rth coin (0-indexing). Now we are iterating from the last coin. We can either take rth coin and add up rec(x — c[r], r) to our answer or we can not take the rth coin and simply add up rec(x, r-1) (the answer by taking up to (r-1)th coin). So we have:

dp[i][j] = dp[i - c[j]][j] + dp[i][j - 1]

We also do dp[i][j] %= MOD to prevent overflow.

What could be the possible reason for Time Limit Exceeded? Thank you.

UPD: One person in the comments told that it is because constraints on CSES are tight and that's why recursion might give a TLE on CSES. I think that answers the question.

UPD: This is the exact reason for the TLE

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it