andmej / acm

My solutions for problems from the UVa Online Judge (Valladolid).

This URL has Read+Write access

acm / 10098 - Generating fast, sorted permutation / 10098.cpp
100644 21 lines (18 sloc) 0.311 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <algorithm>
#include <string>
 
using namespace std;
 
int main(){
  int n;
  cin >> n;
  while (n--){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    do{
      cout << s << endl;
    }while(next_permutation(s.begin(), s.end()));
    cout << endl;
  }
  return 0;
}