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. C和C#两种方式实现邮件的简单接收

    本文的主要内容是通过两种方式实现简单邮件的接收,一种方式是通过C语言实现,另一种是通过C#实现的, 两种方式在实现上有许多的不同之处,但是本质上都是一样的. 一,C语言实现方式 C语言接收邮件的步骤: ...

  2. .Net遍历窗体上控件

    实现遍历窗体上的控件以及找出TextBox控件,代码如下: foreach( Control control in this.Controls ) { if( control is TextBox ) ...

  3. 基于usb4java实现的java下的usb通信

    项目地址:点击打开 使用java开发的好处就是跨平台,基本上java的开发的程序在linux.mac.MS上都可以运行,对应这java的那句经典名言:一次编写,到处运行.这个项目里面有两种包选择,一个 ...

  4. 使用Bind读取配置到C#的实例

    在之前的一篇二级域名绑定的文章<.Net Core 二级域名绑定到指定的控制器>中,有一个小的地方是关于读取Json文件的配置信息的,当时是用了读取文件流的方式,一直以来觉得该方法太Low ...

  5. 【hive】在alter修改元数据的时候报错 mismatched input 'xxxxx' expecting KW_EXCHANGE

    目的:修改表某个字段属性 语句: 报错信息 错误原因: 在HiveQL中,alter命令不使用与create或select相同的语义 ; 具体来说,您不能使用“ALTER DATABASE.TABLE ...

  6. JDK的KeyTool和KeyStore等加密相关

    Keytool是一个有效的安全钥匙和证书的管理工具. Java 中的 keytool.exe (位于JDK\Bin下)可以用来创建数字证书,所有的数字证书是以一条一条(用别名区别,不区分大小)地存储在 ...

  7. C++多线程1.createthread

    C++ 多线程知识1.多线程入门 CreateThread 20131021 1.介绍WinAPI中的CreateThread 函数原型: HANDLE WINAPI CreateThread( LP ...

  8. bzoj1711

    题解: 原点->食物建一个1 食物->牛见一个1 牛->牛'见一个1 牛'->饮料1 饮料->汇点1 代码: #include<cstdio> #includ ...

  9. Markdown_00_资源帖

    一.官方资料 1.原始官方文档 daringfireball.net 2.官方文档中文版 Markdown 语法说明 (简体中文版) Markdown: Basics (快速入门) 3.Typora官 ...

  10. LeetCode OJ:Jump Game II(跳跃游戏2)

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...