Блог пользователя WayBig

Автор WayBig, история, 11 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор WayBig, история, 12 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -20
  • Проголосовать: не нравится

Автор WayBig, история, 12 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится