Editorial for COCI '13 Contest 6 #2 Font
Submitting an official solution before solving the problem yourself is a bannable offence.
We need to find the number of different subsets of the set of given words such that the combined words in the subsets contain all lowercase letters of the English alphabet. In a set of
A regular way of passing through all subsets of a set is using a recursive function.
f( i ):
if i = N + 1: check whether the inserted sets contain the whole alphabet
(we've passed through all words)
else:
add the i'th word to the set
call f( i + 1 )
remove the i'th word from the set
call f( i + 1 )
Additionally, we need to decide how to represent these sets in the computer's memory so we could implement the addition and removal of a word in the set.
One possible way is using an array
When we add a word to the subset, we increment the counter in the array
The complexity of this algorithm is
Another way of representing sets of letters in the computer's memory is using a bitmask. A bitmask is a series of ones and zeroes where the
The advantage of this implementation of sets in the memory is because the processor deals with bitwise operations really quickly, the complexity being
The complexity of the algorithm when using this kind of implementation of set operations is
Comments