Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int a;
- cin >> a;
- vector<string> input;
- for (int i = 0; i < a; ++i) {
- string tmp;
- cin >> tmp;
- input.push_back(tmp);
- }
- unordered_map<bitset<26>, vector<string> > m;
- for (auto& x : input) {
- bitset<26> b;
- for (auto& y : x) {
- b[y - 'a'] = 1;
- }
- if (m.contains(b)) {
- m[b].push_back(x);
- } else {
- m[b] = {x};
- }
- }
- for (auto& x : m) {
- for (auto &y: x.second)
- cout << y << ' ';
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement