Faraz's blog

By Faraz, history, 3 hours ago, In English

Hello Codeforces!

I submitted my solution for 2275D - Precision Alignment , but I'm getting WA 2 I have spent a while trying to find where my logic fails or what edge case breaks my binary search check function, but I haven't been able to spot the bug yet.

My Approach: Binary Search on Answer: I am binary searching for the answer mid in the range [-3e18, 3e18] using __int128 arithmetic to prevent overflow.

Check Function (check(mid)): For each element/triplet $$$A[i] = (a, b, c)$$$, I evaluate if we can meet or adjust the condition using available operations $$$k$$$: Compute signs of differences: $$$a - b$$$, $$$a - c$$$, and $$$b - c$$$.If $$$a = b = c$$$, I immediately return false. If the signs indicate a non-increasing state ($$$\le 0$$$) , I calculate the minimum operations needed (sm1) by adjusting values (using delta logic with abs) and adding the remaining needed magnitude to reach mid Accumulate total operations into op and ensure op <= k.

My Submission : 393623669

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

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

im unable to open ur submission can you send ur code to me somehow maybe write it in reply or write it in ideone and send me the link

  • »
    »
    3 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    Spoiler
    • »
      »
      »
      2 hours ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      tho this code gave some compilation errors which I needed to fix for some reason but yeah I found this case:

      Test Case

      here is a possible explanation:

      Explanation + fix

      the fix mentioned above did give me an ac here is the corrected sgn == -1 if you need it:

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

        Oh got it my bad.

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

          yes but next time let us spy on your code if you want us to fix it. Lemme see ur submissions

          // WHY DO YOU KEEP SPYING ON MY CODE GO SOLVE A PROBLEM -_-

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

            Permission granted for you :)

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

              I want permission too

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

                for hacking my code next time? -_-

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

                  yes :)

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  71 minute(s) ago, hide # ^ |
                   
                  Vote: I like it 0 Vote: I do not like it

                  nah :)