lecxe's blog

By lecxe, 10 months ago, In English

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)?

Full text and comments »

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

By lecxe, 11 months ago, In English

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)

Full text and comments »

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

By lecxe, 11 months ago, In English

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

Full text and comments »

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

By lecxe, 11 months ago, In English

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

Full text and comments »

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

By lecxe, 15 months ago, In English

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

Full text and comments »

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

By lecxe, history, 16 months ago, In English

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

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By lecxe, history, 16 months ago, In English

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?

Full text and comments »

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