you can also use von Neumann ordinals for each number, I think an implementation of this with the next_permutation algorithm could lead a O(n!.2^n.n^2) complexity, which probably would lead to TLE for almost every program
2010/5/4 Leopoldo Taravilse <ltaravi...@gmail.com> > I think the following is a better way to find faster all the permutations > of a string: > > 1) sort the string > > 2) repeat the following: > > look for the first i such that from string[i] to string[string.size()-1] > it's not sorted backwards, change string[i] for then next char in > lexicographical order from among the chars in > string[i+1]..string[string.size()-1] and sort that substring (you can do it > in o(n)) that takes o(n!*n). I think yours too but I think this is the > better way to do it fast. > > -- > You received this message because you are subscribed to the Google Groups > "google-codejam" group. > To post to this group, send email to google-c...@googlegroups.com. > To unsubscribe from this group, send email to > google-code+unsubscr...@googlegroups.com<google-code%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > -- Walter Erquínigo Pezo Every problem has a simple, fast and wrong solution. -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to google-c...@googlegroups.com. To unsubscribe from this group, send email to google-code+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.