ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1425. Queen 2

std::prev_permutation
Posted by Lomir 30 Jun 2007 01:55
http://www.cplusplus.com/reference/algorithm/prev_permutation.html
"If the function can determine the previous smaller permutation, it rearranges the elements as such and returns true. If that was not possible (because it is already at the smallest), it rearranges the elements according to the last permutation (sorted in descending order) and returns false."

On Timus std::prev_permutation function doesn't return false ever.

This code gets TLE:

    std::vector<int> v(5);
    for (int i = 0; i < 2; ++i)
        v[i] = 1;
    while (std::prev_permutation(v.begin(), v.end()));