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

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

In this problem, my solution (code starts at line 71) is getting Wrong Answer.
I read the editorial.
My solution is the same as the editorial but without binary search.
I wrote a stress test which compared my solution with the editorialists code.
Using large T for different values of N, I could find no case where my answer was different.

stress test code

I cannot find any mistake in my logic or implementation.
Any help would be appreciated.

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

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Fails on test case: 1 7 1 2 3 4 5 8 5

Expected: 13 Got: 9

PS:

  1. Is this your code? Looks like a poorly copied code or poorly copied idea from Editorial and coding it specially the lines inside if and checking DP

  2. You can refer to my code here. It uses the same idea as yours but instead of manually checking, I used rangePattern sum which is from this start to this end I want the pattern to match for all bits and used DP to make it faster. You can use SOS DP or trie as well

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    1. Yes, this is my in contest submission.
    2. I am aware of the different ways to solve this but I was looking to fix the mistake in my way (which I believe is the most efficient way possible).

    Good news, I fixed the bug (which was a missing "-1") and it got Accepted!
    PS: Why does my code look like it was copied?

    • »
      »
      »
      15 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Congratulations. I also got AC using your code just now XD. Apologies for the PS-1, let's say, I saw this pattern vector<pair<ll, ll>> bits(60); and few more somewhere(wink). People can have similar code block and names but usually like what are the odds. Still my bad for misjudging.

      • »
        »
        »
        »
        15 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        No problem.
        By the way, in your code, you used #define int long long;
        It invokes undefined behaviour.
        Read "Reserved Macro names" on this website (int is a keyword).

        "A translation unit that uses any part of the standard library is not allowed to #define or #undef names lexically identical to ... keywords ... Otherwise, the behavior is undefined".