The stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are stored in the same warehouse (i.e. in the same building) labelled with this letter. During the day the stores manager receives and books the orders of goods which are to be delivered from the store. Each order requires only one kind of goods. The stores manager processes the requests in the order of their booking. 
You know in advance all the orders which will have to be processed by the stores manager today, but you do not know their booking order. Compute all possible ways of the visits of warehouses for the stores manager to settle all the demands piece after piece during the day. 

Input

Input contains a single line with all labels of the requested goods (in random order). Each kind of goods is represented by the starting letter of its label. Only small letters of the English alphabet are used. The number of orders doesn't exceed 200. 

Output

Output will contain all possible orderings in which the stores manager may visit his warehouses. Every warehouse is represented by a single small letter of the English alphabet -- the starting letter of the label of the goods. Each ordering of warehouses is written in the output file only once on a separate line and all the lines containing orderings have to be sorted in an alphabetical order (see the example). No output will exceed 2 megabytes. 

Sample Input

bbjd

Sample Output

bbdj
bbjd
bdbj
bdjb
bjbd
bjdb
dbbj
dbjb
djbb
jbbd
jbdb
jdbb
全排列 开始不知道有全排列的函数,半天没写出来
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#define maxn 10010
using namespace std;
int main()
{
char str[];
while(cin >> str)
{
getchar();
sort(str,str+strlen(str));//排序
do
{
cout << str << endl;
}
while(next_permutation(str,str+strlen(str)));//全排列函数
}
return ;
}

Orders POJ - 1731的更多相关文章

  1. POJ 1731 Orders(STL运用)

    题目地址:POJ 1731 这题能够直接用STL函数做,非常轻松..next_permutation函数非常给力.. 代码例如以下: #include <algorithm> #inclu ...

  2. poj 1731 Orders

    http://poj.org/problem?id=1731 Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9 ...

  3. poj 1731 Orders(暴力)

    题目链接:http://poj.org/problem?id=1731 思路分析:含有重复元素的全排列问题:元素个数为200个,采用暴力枚举法. 代码如下: #include <iostream ...

  4. POJ 1731:Orders

    Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9940   Accepted: 6048 Descriptio ...

  5. POJ 1731

    #include<iostream> #include<string> #include<algorithm> using namespace std; int m ...

  6. Day4 - H - Following Orders POJ - 1270

    Order is an important concept in mathematics and in computer science. For example, Zorn's Lemma stat ...

  7. 是时候学一波STL了。。。

    都到如今了还不会STL,赶紧学习一下. .. 头文件#include<algorithm> 加上 using namespace std. 求下一个排列的函数:next_permutati ...

  8. POJ 1270 Following Orders

    Following Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4902   Accepted: 1982 ...

  9. POJ 1270 Following Orders 拓扑排序

    http://poj.org/problem?id=1270 题目大意: 给你一串序列,然后再给你他们部分的大小,要求你输出他们从小到大的所有排列. 如a b f g 然后 a<b ,b< ...

随机推荐

  1. python3 实现多域名批量访问特定目录(一)

    渗透测试之批量处理同一框架CMS系统漏洞 当我们做多网站的渗透测试时,会发现很多站点采用的都是同类型的CMS框架,只要我们发现一个漏洞,那么我们可以批量处理这一类站点,高效测试,如果不知道该站点的框架 ...

  2. JAVA-基础-数据类型转换

    一.类型的转换 java中数据具有类型.这些类型是可以相互进行转换的. 1.自动类型转换 六个和数字相关的基本类型,可以自动由小到大进行类型转换.但是反过来就不行. *注意,在整形自动转浮点型时,有可 ...

  3. 2. 源码分析---SOFARPC客户端服务引用

    我们先上一张客户端服务引用的时序图. 我们首先来看看ComsumerConfig的refer方法吧 public T refer() { if (consumerBootstrap == null) ...

  4. JavaSE之——并没有多维数组

     近日在读<疯狂Java讲义>精粹第二版,部分语述摘自其中,自己边敲边理解 前言       我们知道,Java语言支持的类型有两种:            1.基本类型(即八大基本数据类 ...

  5. Codeforces 468C Hack it!

    https://www.luogu.org/problemnew/show/CF468C http://codeforces.com/contest/468/problem/C #include &l ...

  6. 一文了解:Redis的RDB持久化

    一文了解:Redis的RDB持久化 Redis是内存数据库,为了保证数据不在故障后丢失,Redis需要将数据持久化到硬盘上. Redis持久化有两种方式:一种是快照,全量备份.一种是AOF方式,连续增 ...

  7. C# 在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级

    //使用委托进行修改UI界面 if (this.InvokeRequired) { this.Invoke(new MethodInvoker(delegate { createList(); })) ...

  8. 3、K-近邻算法

    K最近邻(k-Nearest Neighbor,KNN)分类算法 1.定义:如果一个样本在特征空间中的k个最近似(即特征空间中最临近)的样本中大多数属于某一类别,则该样本也属于这个类别. 2.计算公式 ...

  9. WPF中ComboBox控件绑定键值对操作

    WPF中下拉框将键值对作为其数据源的具体操作.本实例以枚举类型以及枚举特性描述字符串生成键值对来进行. namespace ViewC { /// <summary> /// View.x ...

  10. 60701BMP彩色图像转化为灰度及二值图像

    1 概述 多媒体技术是一门综合了多种学科的新技术,其涉及到计算机科学与技术.通信和网络技术.人工智能技术.微电子技术.数字信号处理.图形处 理技术.声像技术等诸多学科.许多新技术的不断出现和体验,带给 ...