Editorial for CCC '17 J3 - Exactly Electrical


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Kirito

For this problem, we make the observation that if the car can reach any intersection (x, y) using n electric charges, it can do so in n+2 charges. This means that if the number of charges left over after reaching (c, d) is a non-negative even number, then we should output Y, otherwise output N.

Time Complexity: \mathcal O(1)


Comments


  • 2
    DavidLiuzhw  commented on Feb. 2, 2022, 11:22 p.m.

    My solution adheres to this principle but it still only gets 9/15


    • 3
      Champion52  commented on Nov. 19, 2022, 7:03 p.m.

      the number of charges left can be 0