your.nemesis's blog

By your.nemesis, history, 12 months ago, In English

I have had this doubt in dynamic programming for a long time now regarding which states to use. The question goes something like this:

Reading Input:

Recursion Code: So from the basic intuition I wrote this code. Which is obviously MLE:

Then I tried this code:

And this code passed the test cases and got AC. So now coming back to my doubt. There have been many problems where

$$$ dp[i][j][k] --> $$$ is optimized to $$$--> dp[i][j] $$$ because the state j is always changing. But I have also practiced questions where trying this $$$ dp[i][j][k] --> $$$ is optimized to this --> $$$ dp[i][j] $$$ and it got me a WA.

So can someone please explain when to take a state into consideration so that I dont fall into this MLE trap again in the near future?

Thank you:)

Full text and comments »

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

By your.nemesis, history, 14 months ago, In English

Problem Link

There is a possible solution to this problem using the Burnside Lemma. I am just curious if there is any other way to solve this problem using basics of combinatorics.

Burnside Lemma/ Orbit COunting theorem

Thank you!

Full text and comments »

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