This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "tools/next_permutation.hpp"
template <typename Iterator>
bool next_permutation(Iterator first, Iterator k, Iterator last);
It generates the next permutation as n-choose-r.
It returns true
if the next permutation exists, false
otherwise.
// 9-choose-3
int k = 3;
do {
std::cout << std::string(s.begin(), std::next(s.begin(), k)) << std::endl;
} while (tools::next_permutation(s.begin(), std::next(s.begin(), k), s.end()));
first
$\leq$ k
$\leq$ last
#ifndef TOOLS_NEXT_PERMUTATION_HPP
#define TOOLS_NEXT_PERMUTATION_HPP
#include <algorithm>
namespace tools {
template <typename Iterator>
bool next_permutation(const Iterator first, const Iterator k, const Iterator last) {
::std::reverse(k, last);
return ::std::next_permutation(first, last);
}
}
#endif
#line 1 "tools/next_permutation.hpp"
#include <algorithm>
namespace tools {
template <typename Iterator>
bool next_permutation(const Iterator first, const Iterator k, const Iterator last) {
::std::reverse(k, last);
return ::std::next_permutation(first, last);
}
}