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

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

I want to check a solution which I believe is wrong from yesterday's contest (Edu Round 161)

How can I hack/check that now (after the hacking phase)?

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

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

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

Does anyone know where I can get USACO old problems?

I saw this blog on CF: https://codeforces.net/blog/entry/95032

But it prolly doesnt have the ones which arent on the official site (I tried accessing JAN 2011 questions, link isn't working)

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

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

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

The editorial at times becomes difficult to understand

I liked this blog from site: https://www.cnblogs.com/cjjsb/p/16882203.html

And translate does make it pretty understandable

Was curious, what are other different sites where the solutions get discussed? Maybe Chinese, Japanese..or any language as we can translate it

Coders from different regions can you drop in the sites you know/like to read

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

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

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

Question: https://codeforces.net/problemset/problem/1906/M

Editorial: https://competition.binus.ac.id/icpc2023/M5xmtK1iPAdXT1t765fbLg5m66d52XuT.pdf

The second part in the editorial where $$$M \le 2 \cdot (S - M)$$$

I read it, but still feel I don't quite get it.
Can someone please help me to understand the math of the second part

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

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

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

Question:

A boat can carry at max a weight of W.

There are N people, with weight w_i.

Once the boat crosses the river it never returns.

We have to tell the no. of different groupings possible of people

Solve for T testcases

Input:

T 
N W
w_1, w_2, ... w_N
1 <= T <= 100
1 <= N <= 30
1 <= w_i, W <= 2 * 1e9

NOTE: not choosing any person and just passing the boat is also valid.

Sample:

Can someone please help. Thank you

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

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

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

I am getting MLE for the question: https://codeforces.net/contest/1855/problem/C1 (one of the recent div2 contests)

submission link : https://codeforces.net/contest/1855/submission/217028542

The approach that I am trying:
1. To increase the positive element greater than 20
2. make the index-1 greater than 0 with the help of max value index. (0 based indexing)
3. now increase the values incrementally

I am getting problem for the case, where there is a positive number present in the array ( I know this because if I assert the size, I get the runtime error )

snippet where the code gives problem

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

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

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

Question https://cses.fi/problemset/task/1636/

My code: https://pastebin.com/Ex76qD5f


I know for some problems where in dp state, the transitions go from (i,j) -> (i+1, j) or (i, j) -> (i-1, j)
in this case we can make the dp storage as dp[2][maxJ] instead of dp[maxI][maxJ]

But is there a way I can do the same when I have already written the code in recursive fashion?

or make just few changes to code so to apply this (i.e dp[2][maxJ]) optimization, instead of writing the iterative code again to apply the optimization.

NOTE: I want to know if I can apply this optimization for a general case? Or it is necessary to write iterative code to apply it?

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

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