EPN's blog

By EPN, history, 7 weeks ago, In English,

Hi, I noticed that I never think about sets when trying to solve a problem even when it is quite clear a set is the way to go. Do any of you know about a problemset or even a single problem in which using a set is a good way to solve it?

Just to contribute a little bit myself, I will link this problem: 1277B - Сделай нечетными

 
 
 
 
  • Vote: I like it
  • -18
  • Vote: I do not like it

»
7 weeks ago, # |
Rev. 2   Vote: I like it -16 Vote: I do not like it

Check the following problem 1312B - Bogosort which can be solved using a C++ STL std::multiset container. Note that multiset is similar to C++ STL std::set container as keys are sorted by specific order. However, multiple keys with equivalent values are allowed to exist in multisets, whereas keys with equivalent values are not allowed to exist in set, i.e. each key in the sorted set has a distinct value that is different from all other values, even though the same value might have been inserted to the container several times. In other words, inserting a key value to a set container in which this value already exists does not increase the size of the container.