From 96254947699986c59f0dc63d69fd4b76bd3ed43e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Jul 2026 19:08:08 +0200 Subject: Initial commit --- 01_introductory_problems/creating_strings_1622.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 01_introductory_problems/creating_strings_1622.cpp (limited to '01_introductory_problems/creating_strings_1622.cpp') diff --git a/01_introductory_problems/creating_strings_1622.cpp b/01_introductory_problems/creating_strings_1622.cpp new file mode 100644 index 0000000..689e083 --- /dev/null +++ b/01_introductory_problems/creating_strings_1622.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +void gen(std::map& a, int count, + std::string start, std::vector& res) { + if (count == 0) + res.push_back(start); + for (auto [k, v] : a) { + if (v > 0) { + a[k]--; + gen(a, count - 1, start + k, res); + a[k]++; + } + } +} + +int main() { + std::string s; + std::map a; + std::vector sol; + std::cin >> s; + for (auto c : s) + a[c]++; + gen(a, s.size(), "", sol); + std::cout << sol.size() << "\n"; + for (auto x : sol) + std::cout << x << "\n"; +} -- cgit v1.3