Editorial for SAC '22 Code Challenge 4 Junior P2 - Obligatory Geometry Problem


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 maintain a string that stores the type of the current shape:

  • If it is a set query, update the string to that shape.

  • If it is a get query, output 1 if the string and query shape are the same and output 0, otherwise.

Time Complexity: \mathcal{O}(Q)

Subtask 2

Extend the subtask 1 solution by giving each of the N shapes a string by defining an array.

Further, maintain the string for each of the N shapes:

  • If it is a set query, update the string at index i to that shape.

  • If it is a get query, output 1 if the string at index i and query shape are the same and output 0, otherwise.

Time Complexity: \mathcal{O}(Q)


Comments

There are no comments at the moment.