hrishabhpatel09's blog

By hrishabhpatel09, history, 2 days ago, In English

Here is a Problem: 2069B - Set of Strangers Here is Soln: 306760751

»
39 hours ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

CounterEX

1

4 4

1 1 2 2

1 1 2 2

3 3 4 4

3 3 4 4

output : 12

ans : 6

  • »
    »
    39 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Any number in any arrangement can be changed into any other number with one or at most two changes.

    • »
      »
      »
      37 hours ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks for helping, i understood it in wrong way. I thought we have to pick same color from unconnected component and then in one move we can color these to any other color

»
90 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Bro tune third question 2069C - Beautiful Sequence,dp ka implementation kaise kiya hai yeh bata sakta hai , like approach mujhe bhi aagayi thi but i don't know how to implement it

  • »
    »
    78 minutes ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    good subsequences are of form 12222....3. count of 2s >= 1 and start me 1 and end me 3.

    // dp[i][1] bolega no of subsequences of form "1" till i // dp[i][2] bolega no of subsequences of form "122...." till i // dp[i][3] bolega no of subsequences of form "12....3" till i

    // dp[i][1] ,agar a[i] == 1, dp[i][1] = 1 + dp[i-1][1], nhi toh base dp[i][1] = dp[i-1][1]

    // dp[i][2], agar a[i] != 2 toh dp[i][2] = dp[i-1][2] // but if a[i] == 2 // i-1 tak jo already 12... bangayi ume 2 jod de, ya mat jod. total 2 * dp[i-1][2] hojayengi // i-1 tak jo no of form "1" ki subsequences hai unme 2 jod de, toh dp[i — 1][1] // so dp[i][2] = dp[i — 1][1] + 2 * dp[i — 1][2]

    //dp[i][3], i-1 tak jo already 12.... bangayi unme 3 jod de bas, dp[i][3] = dp[i-1][2]

    • »
      »
      »
      10 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      very thanks bhai , from now i will post my each doubt in community it is very helpful