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. Hibernate与 MyBatis的比较(转,留作以后细细钻研)

    最近做了一个Hibernate与MyBatis的对比总结,希望大家指出不对之处. 第一章     Hibernate与MyBatis Hibernate 是当前最流行的O/R mapping框架,它出 ...

  2. 【转】Scikit-learn技巧(拓展)总结

    最近看了<Python数据挖掘入门与实战>,网上有说翻译地不好的,但是说实话,我觉得这本书还是相当不错的.作者Robert Layton是sklearn的开发者之一,书中介绍了很多skle ...

  3. setTimout执行时间

    在浏览器中,JavaScript引擎是单线程执行的.也就是说,在同一时间内,只能有一段代码被JavaScript引擎执行.页面加载时,JavaScript引擎会顺序执行页面上所有JavaScript代 ...

  4. [postgresql]ROWS is not applicable when function does not return a set问题解决

    需要把程序结尾的ROWS 1000去掉,提示如果函数不是返回一个数据集的情况下ROWS是不适用的: CREATE OR REPLACE FUNCTION public.function( eigyou ...

  5. Android 版本升级涉及到的数据库数据迁移问题

    最近做老版本向新版本升级,新版本增加了几张表,有的表经过了增加字段.那么如何把老的数据迁移到新的版本里呢? 我写了一段伪代码,是关于我们项目里的 用户登录信息 Users表,    历史表histor ...

  6. JWT(JSON Web Token) Java与.Net简单编码实现

    参考 JWT(JSON WEB TOKENS)-一种无状态的认证机制 基于Token的WEB后台认证机制 各种语言版本的基于HMAC-SHA256的base64加密 Java与.Net实现实现 // ...

  7. PHP---初探PHP

    初探PHP 虽然说前后端分离,但作为前端还是要跟数据打交道的,所以对后台语言的了解还是很有必要的.今天要学的就是PHP. 什么是PHP? PHP(外文名:PHP: Hypertext Preproce ...

  8. Idea_03_常用快捷键

    一.前言 这一节我们来看下Idea的一些常用快捷键 二.常用快捷键 Alt + Enter 有错误.警告时的提示 Ctrl+Shift+R 全局 打开资源 ctrl + F 在当前文件查找或替换 Ct ...

  9. LeetCode OJ:Number of Islands(孤岛计数)

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  10. SpringInAction--自动化装配Bean(隐式装配)

    关于Bean的介绍就具体不多介绍了,,, Spring在配置时候有三种方案可选 1.在xml中进行显示配置 2.在java中进行显示配置 3.隐式的Bean发现机制和自动装配 今天学习的就是自动化装配 ...