Editorial for SAC '22 Code Challenge 5 Junior P3 - Media List
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
Maintain a set of distinct names with a built-in data structure provided in your language (e.g., set<int>
for C++).
For each type query, output 1
if the set contains or 0
if it does not.
For each type query, insert into the set.
Note that a dynamic array is insufficient since could be at the end of the array for type queries and blow up the solution to .
Time Complexity:
Subtask 2
Instead of using one set, define an array of sets.
The same logic as subtask applies.
Time Complexity:
Comments