c++ - Listing specific subsets using STL -


say have range of number, {2,3,4,5}, stored in order in std::vector v, , want list possibles subsets end 5 using stl... :

2 3 4 5 2 3 5 2 4 5 3 4 5 2 5 3 5 4 5 5 

( hope don't forget any:) )

i tried using while(next_permutation(v.begin(),v.end())) didn't come wanted result :)

does have idea?

ps : have done archives of google code jam 2010 may recognize :)

tomasz describes solution workable long n<=32 although take very long time print 2^32 different subsets. since bounds large dataset 2 <= n <= 500 generating subsets not way go. need come clever way avoid having generate them. in fact, whole point of problem.

you can find solutions googling problem if want. hint need @ structure of sets , avoid generating them @ all. should calculate how many there are.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -