Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss195 - | Accepted | C++11 | 0.000 | 0.000 | 354 | 1 mins ago |
#include <bits/stdc++.h>
using namespace std;
int t;
bool comp(char x, char y){
int xx=0, yy=0;
if (x < 'a'){
xx= -1;
x += 32;
}
if (y < 'a'){
yy= -1;
y += 32;
}
if (x==y) return xx < yy;
else return x < y;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t;
while(t--){
string s;
cin >> s;
sort(s.begin(), s.end(), comp);
do{
cout<<s<<"\n";
}while(next_permutation(s.begin(), s.end(), comp));
}
}
No comments:
Post a Comment