Editorial for SAC '22 Code Challenge 5 P2 - Querying Extensions


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: maxcruickshanks

Subtask 1

It suffices to hard code the output for every N and left or right.

Time Complexity: \mathcal{O}(1)

Subtask 2

Realize that this is a parity problem:

  1. If N \equiv 1 \pmod 2, then the output is the same as the original swaying direction.
  2. Otherwise, if N \equiv 0 \pmod 2, then the output is the opposite of the original swaying direction.

Output the direction based on the two cases.

Time Complexity: \mathcal{O}(1)


Comments

There are no comments at the moment.