-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path195 Anagram.cpp
More file actions
48 lines (44 loc) · 1.01 KB
/
Copy path195 Anagram.cpp
File metadata and controls
48 lines (44 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define _CRT_SECURE_NO_WARNINGS
//#include "AllClasses.h"
#include <bits/stdc++.h>
using namespace std;
#define OO 1000000000000000007
#define oo 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 15;
string in;
struct Comp {
bool operator() (string a, string b) {
for (int i = 0; i<a.size(); i++)for (int j = 0; j<b.size(); j++) {
if (a[i] == b[i]) continue;
if (tolower(a[i]) == tolower(b[i])) {
return (b[i] == tolower(b[i])) ? 1 : 0;
}
else return (tolower(a[i]) <= tolower(b[i]));
}
}
};
set<string, Comp>st;
void Solve(string s) {
sort(s.begin(), s.end());
do {
st.insert(s);
} while (next_permutation(s.begin(), s.end()));
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
int k;
scanf("%d", &k);
for (int i = 0; i<k; i++) {
cin >> in;
Solve(in);
for (auto i = st.begin(); i != st.end(); i++) cout << *i << endl;
st.clear();
}
return 0;
}