setlocale(LC_ALL, "ru-RU.UTF8");
if (argc == 1) {
std::cerr << "Error: Alphabet file not specified\n";
return 1;
}
std::unordered_map <wchar_t, int> alphabet;
std::wifstream alphabet_file(argv[1]);
if (!alphabet_file) {
std::cerr << "Error: Alphabet file not found\n";
return 1;
}
alphabet_file.imbue(std::locale("ru-RU.UTF8"));
template<class ForwardIt, class UnaryPredicate>
ForwardIt npartition(ForwardIt first, ForwardIt last, UnaryPredicate&& p) {
first = std::find_if_not(first, last, p);
if (first == last) return first;
for (ForwardIt i = std::next(first); i != last; ++i) {
if(p(*i)) {
std::iter_swap(i, first);
++first;
}
}
return first;
}
void divisible_func(std::vector<int>& a, const std::vector<int>& b) {
auto it = a.end();
for(size_t i = 0, j = 0; i < b.size(); ++i, j=0) {
it = npartition(a.begin(), it, [&] (int) {
return ((j++ % b[i]) != 0); // в левой части a соберутся j % b[i] != 0
});
}
a.erase(it, a.end());
a.push_back(-1); // ????????????????
}