MuhammadSawalhy's blog

By MuhammadSawalhy, 13 months ago, In English

In the recent Div 3, I was rushing to submit fast to reduce the penalty so I miss-typed this part of the code:

            if (j + tochange[i])
                dp[i + 1][j + tochange[i]] = dp[i + 1][j + tochange[i]] | dp[i][j];

It should be:

            if (j + tochange[i] <= n)
                dp[i + 1][j + tochange[i]] = dp[i + 1][j + tochange[i]] | dp[i][j];

Can you hack my submission, please?: 203309510

Update:

Solution verdict: Wrong answer

Congratulations Yousef-Elwan!

But why my solution didn't get RTE?

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

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

It seems I'm the only person who solved it like this (with DP). So, now I'm unsure about my idea and don't have firm proof.

You can go ahead and try hacking with wrong answers as well.

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Could you explain your idea,please?

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I need to choose some letters that are the same on both sides with other letters that are the same as well so we fix two in just one operation (greedily).

    So I need to choose some of these letters that their count is the closest to (total / 2).

    Example:

    1
    8
    abcaadba
    

    We notice that the letters the need to be fixed are:

    ab aa ba
    

    After one operation:

    aa ba ba
    a      a
    

    That last one can be fixed in one operation.

    You can solve this DP problem first to understand the idea: https://cses.fi/problemset/task/1093.

    The flaw here is that, I either take all of "a" for example and swap them with others or leave them all.

»
13 months ago, # |
  Vote: I like it +6 Vote: I do not like it

Wow you're the guy from fegla senior training

»
13 months ago, # |
  Vote: I like it +4 Vote: I do not like it

I think it's a wrong idea, not only that it crossed n