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 输出有重复字符的全排列,dfs。 代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <map> using namespace std;
int vis[],n;
char b[];
void dfs(int k)
{
if(k == n)
{
cout<<b<<endl;
return;
}
for(int i = ;i < ;i ++)
{
if(!vis[i])continue;
vis[i] --;
b[k] = 'a' + i;
dfs(k + );
vis[i] ++;
}
}
int main()
{
char ch;
while((ch = cin.get())!='\n')
{
n ++;//记录字符个数
vis[ch - 'a']++;//记录每个字母的个数
}
b[n] = '\0';
dfs();
}

Orders的更多相关文章

  1. POJ1270 Following Orders[拓扑排序所有方案 Kahn]

    Following Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4885   Accepted: 1973 ...

  2. Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'orderdetails' of 'class com.luchao.mybatis.first.po.Orders' with value 'Orderdetail [id=null, ordersId=3, itemsId=1, it

    从上面异常的解释来看是因为反射不能将Orders设置到orderdetails属性上,仔细检查了MyBatis的配置文件,发现: <collection property="order ...

  3. poj 1731 Orders

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

  4. 8.1:SportsStore:Orders and Administration

    本章,作者将通过收集和验证购物明细,来完成SportsStore应用,并在Deployd服务器上存储该订单.作者也构建了一个管理应用,允许认证用户查看订单,和管理产品分类. 1.准备实例项目 2.获取 ...

  5. POJ1270 Following Orders (拓扑排序)

    Following Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4254   Accepted: 1709 ...

  6. 生成订单:三个表(Products,Orders,OrderItem)

    1.有三个表(Product上,Orders,OrderItem) 分别创建对应的三个实体类 OrderItem中有外键Order_id 参考Orders中的id :Product_id参考Produ ...

  7. POJ 1270 Following Orders

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

  8. How to Manage Amazon-Fulfilled Orders - Cancel an Amazon-Fulfilled Order

    You may request to cancel customer orders that have a status of "Pending" or "Unshipp ...

  9. 错误代码: 1142 REFERENCES command denied to user 'wuyong'@'localhost' for table 'orders'

    错误代码: 1142 REFERENCES command denied to user 'wuyong'@'localhost' for table 'orders' 原因:在使用SQLyog操作数 ...

随机推荐

  1. centos cgroup配置

    centOS 6:1. 启用cgroup    查看内核是否支持cgroup功能:cat /boot/config-`uname -r` | grep -i rt_group    查看支持的子系统: ...

  2. Java循环跳转语句之 continue

    continue 的作用是跳过循环体中剩余的语句执行下一次循环. 例如,打印 1--10 之间所有的偶数,使用 continue 语句实现代码为: 运行结果: continue与break的区别就是, ...

  3. FlatBuffer入门笔记

    FlatBuffer入门笔记 1 flatbuffer资料 flatbuffer下载地址:https://github.com/google/flatbuffers flatbuffer官方使用文档: ...

  4. phalcon: 目录分组后的acl权限控制

    phalcon: 目录分组后的acl权限控制 楼主在做acl权限的时候,发现官方的acl只能针对未分组的目录,如下: app/ ___|./controller ___|./logic ___|./p ...

  5. Resource——资源的总结

    在xaml中,对于Style.DataTemplate.ControlTemplate.StoryBord等资源,可以放在UserControl.Resource.Windows.Resource.C ...

  6. Svn Replacement For Git Stash

    svn 实现git stash类似的功能 % svn diff > WorkInProgress.txt % svn revert -R . <make changes> % svn ...

  7. 【原创】移动端获取用户公网ip,获取用户ip

    有时候某些api需要获取用户的ip , 特此分享一下获取用户公网ip的方法 纯js <script src="http://pv.sohu.com/cityjson?ie=utf-8& ...

  8. 简单的HelloWorld

    简单的HelloWorld 步骤: -加入jar包 -在web.xml中配置DispatcherServlet -加入Spring MVC的配置文件 新建文件springmvc.xml: -编写处理请 ...

  9. Linux命令 ls -l 输出内容含义详解

    Linux命令 ls -l s输出内容含义详解   1. ls  只显示文件名或者文件目录 2. ls -l(这个参数是字母L的小写,不是数字1) 用来查看详细的文件资料 在某个目录下键入ls -l可 ...

  10. java和python互相调用

      java和python互相调用  作者:xuaijun  日期:2017.1.1 python作为一种脚本语言,大量用于测试用例和测试代码的编写,尤其适用于交互式业务场景.实际应用中,很多网管系统 ...