commit c954cebb1e9bbf5267f2d030844a03bc4caf8211
parent 19ab8d476ef42ae0d41b3f811c0dee991c43714e
Author: superpozycja <anna@superpozycja.net>
Date: Sat, 26 Oct 2024 22:58:45 +0200
solve creating strings
Diffstat:
1 file changed, 49 insertions(+), 0 deletions(-)
diff --git a/intro/creating_strings.cpp b/intro/creating_strings.cpp
@@ -0,0 +1,49 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+using ui = unsigned int;
+using l = long;
+using ul = unsigned long;
+using ll = long long;
+using ull = unsigned long long;
+
+using vi = vector<int>;
+using vui = vector<ui>;
+using vl = vector<l>;
+using vul = vector<ul>;
+using vll = vector<ll>;
+using vull = vector<ull>;
+
+set<string> res;
+
+void recurse(string cur, string src)
+{
+ if (src == "") {
+ res.insert(cur);
+ return;
+ }
+
+ for (int i = 0; i < src.length(); i++) {
+ string tmp = src;
+ tmp.erase(i, 1);
+ recurse(cur + src[i], tmp);
+ }
+}
+
+void solve()
+{
+ string l;
+ getline(cin, l);
+ sort(l.begin(), l.end());
+ recurse("", l);
+ cout << res.size() << "\n";
+ for (auto x : res) {
+ cout << x << "\n";
+ }
+}
+
+int main()
+{
+ solve();
+}