Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <unordered_map>
- #include <unordered_set>
- using namespace std;
- #define ll long long
- #define nl endl
- #define cy cout << "YES\n"
- #define cn cout << "NO\n"
- #define sz(s) s.size()
- #define allv v.begin(), v.end()
- #define cin(vec) for (int i = 0; i < n && cin >> vec[i]; i++)
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int n, r;
- multiset<vector<string>> vec;
- vector<string> v;
- vector<string> curr;
- void printVector(vector<string> myVector)
- {
- for (auto element : myVector)
- cout << element << ' ';
- cout << "\n";
- }
- void print(multiset<vector<string>> &multisetOfVectors)
- {
- for (auto it = multisetOfVectors.begin();
- it != multisetOfVectors.end();
- it++)
- {
- printVector(*it);
- }
- }
- void rec(int i)
- {
- if (i > r)
- {
- if (curr.size() == r)
- {
- vector<string> s = curr;
- sort(s.begin(), s.end());
- vec.insert(s);
- }
- return;
- }
- curr.push_back(v[i]);
- rec(i + 1);
- curr.pop_back();
- rec(i + 1);
- }
- void solve()
- {
- cin >> n >> r;
- v = vector<string>(n);
- cin(v);
- rec(0);
- print(vec);
- }
- int main()
- {
- sherry();
- ll t = 1;
- // cin >> t;
- while (t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement