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

Автор Faraz, история, 4 часа назад, По-английски

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

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

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

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 часа назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    Spoiler
    • »
      »
      »
      3 часа назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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
      • »
        »
        »
        »
        3 часа назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        Oh got it my bad.

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

          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 -_-

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

            Permission granted for you :)

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

              I want permission too

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

                for hacking my code next time? -_-

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

                  yes :)

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

                  nah :)