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. 关于ckeditor 之 上传功能

    度了很多文章,看了很多关于ckeditor配置上传功能的文章,没一个写得清楚的, 就是简单的根目录下.config.js 增加 config.filebrowserUploadUrl="/a ...

  2. centos添加php及mysql环境变量

    在Linux CentOS系统上安装完php和MySQL后,为了使用方便,需要将php和mysql命令加到系统命令中,如果在没有添加到环境变量之前,执行 “php -v”命令查看当前php版本信息时时 ...

  3. Delphi.format填充0

    1. ]);// 一共8位数字不够的补零 2. 3. 4. 5.

  4. 微信公众平台开发(一) 配置接口与验证URL

    一.简介 微信公众平台是腾讯公司在微信的基础上新增的功能模块,通过这一平台,个人和企业都可以打造一个微信的公众号,并实现和特定群体的文字.图片.语音的全方位沟通.互动. 二.通讯机制 三.注册微信平台 ...

  5. flask学习(八):页面跳转和重定向

    1. 用处:在用户访问一些需要登录的页面的时候,如果用户没有登录,那么让页面重定向到登录页面 2. 实例 运行效果: 用户已登录,进入发布问答页面 用户未登录,跳转到登录页面

  6. ubuntu 14.04 如何安装nvidia显卡驱动 [转载]

    我的机子装的是64位ubuntu 14.04 LTS系统,显卡是GeForce 405 ,想使用cuda所以需要装NVidia官方驱动,但是总是碰到 nouveau 驱动正在使用的问题.找了好久,网上 ...

  7. dva-loading使用方法

    1. 下载dva-loading npm install dva-loading --save 2. 导入并使用dva-loading import createLoading from 'dva-l ...

  8. 关于px em rem的一点小总结

    2015-11-28 06:06:40 概念 都是CSS单位. px:像素 Pixel.像素 (计算机屏幕上的一个点) em:1em 等于当前的字体尺寸. 2em 等于当前字体尺寸的两倍. 例如,如果 ...

  9. Error:java: Compilation failed: internal java compiler error(转)

    set中java complier 设置的问题  ,项目中有人用jdk1.6  有人用jdk1.7  版本不一样  会一起这个错误 进行如下操作: 原文链接:http://blog.csdn.net/ ...

  10. 海康威视 嵌入到web页面相关问题

    因项目上面需求,接触到了海康威视的设备,要把他嵌入到web页面中,所以就开始了爬坑之路 刚开始不知道如何把设备的页面嵌入到项目的web页面中,直到我遇见了他——“WEB3.0控件开发包V1.0.9_C ...