`
473687880
  • 浏览: 535112 次
文章分类
社区版块
存档分类
最新评论

Generating Fast UVA10098

 
阅读更多

Problem C
Generating Fast, Sorted Permutation

Input:Standard Input

Output:Standard Output

Generating permutation has always been an important problem in computer science. In this problem you will have to generate the permutation of a given string in ascending order.Remember that your algorithm must be efficient.


Input

The first line of the input contains an integer n, which indicates how many strings to follow. The next n lines contain n strings. Strings will only contain alpha numerals and never contain any space. The maximum length of the string is 10.


Output

For each input string print all the permutations possible in ascending order. Not that the strings should be treated, as case sensitive strings and no permutation should be repeated. A blank line should follow each output set.

Sample Input

3
ab
abc
bca

Sample Output

ab
ba

abc
acb
bac
bca
cab
cba

abc
acb
bac
bca
cab
cba


和上一道题差不多,调用STL

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

bool cmp(char ch1,char ch2)
{
    return ch1<ch2;
}

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string str;
        cin>>str;
        sort(str.begin(),str.end(),cmp);
        int i,j;
        cout<<str<<endl;
        while(next_permutation(str.begin(), str.end()))
        {
            cout<<str<<endl;
        }
        cout<<endl;
    }
    return 0;
}






分享到:
评论

相关推荐

    Generating Functionology

    《Generating Functionology》这本书由赫伯特·S·威尔夫(Herbert S. Wilf)编写,是关于生成函数及其在离散数学中的应用的一本著作。本书探讨了生成函数作为离散数学与连续分析之间桥梁的角色,特别强调了它在处理...

    Generating Artifacts问题解决.doc

    ### Generating Artifacts问题解决知识点详解 #### 一、问题背景及概述 在使用MyEclipse进行Web开发过程中,特别是利用Hibernate框架进行数据库反向工程(Hibernate Reverse Engineering)时,可能会遇到名为...

    adv Generating a Map Application源码

    adv Generating a Map Application源码

    adv Generating a Map Application 题目

    adv Generating a Map Application 题目

    Generating Parsers with JavaCC-Centennial

    《Generating Parsers with JavaCC-Centennial》是Tom Copeland撰写的一本书,出版于2009年,主要探讨了如何使用JavaCC工具生成解析器。JavaCC(Java Compiler Compiler)是一个广泛使用的开源工具,它允许开发者用...

    Generating Random Networks and Graphs

    Generating Random Networks and Graphs By 作者: Ton Coolen – Alessia Annibale – Ekaterina Roberts ISBN-10 书号: 0198709897 ISBN-13 书号: 9780198709893 Edition 版本: 1 出版日期: 2017-05-23 pages 页数...

    Episode-Based Prototype Generating Network for Zero-Shot Learnin

    在"Episode-Based Prototype Generating Network for Zero-Shot Learning"这篇论文中,作者提出了一种新的训练框架,用于解决零样本学习(ZSL)中的挑战。这个框架基于episode训练,每个episode模拟一个零样本分类...

    maven \"Generating project in Batch mode\"问题的解决

    当遇到"Maven Generating project in Batch mode"的问题时,通常意味着在批量模式下创建Maven项目时遇到了障碍。这篇博客文章“maven \"Generating project in Batch mode\"问题的解决”可能会提供一些解决方案。 ...

    Generating Searchable Public-Key Ciphertexts With Hidden Structures for Fast Keyword Search

    该研究论文提出了一种名为“带有隐藏结构的可搜索公钥密文(SPCHS)”的概念,其主要目标是加快在加密数据库中对关键词的搜索速度,同时不牺牲加密关键词的语义安全性。接下来我将详细解释文中涉及的主要知识点。...

    Herbert S. Wilf - Generating Functions.pdf

    ### Generating Functions in Discrete Mathematics: An Overview Based on Herbert S. Wilf's Work #### Introduction to Generating Functions Generating functions serve as a bridge between discrete ...

    母函数(Generating function)详解

    母函数,又称生成函数,是数学中一种强大的工具,特别是在组合数学和数论领域。它是一种将序列编码为单一的函数表达式,使得序列的性质可以通过处理这个函数来揭示。母函数通过这种方式提供了序列分析的新视角,使得...

    关于泊松点过程的生成方法-Generating Homogeneous Poisson Processes - PDF.pdf

    关于泊松点过程的生成方法-Generating Homogeneous Poisson Processes - PDF.pdf 在百度上看很多人问平面内泊松点怎么生成,以前我也迷茫的很久,刚好今天找到一个很有用的方法,分享给大家! Report1_...

    Self-generating-code.zip

    标题“Self-generating-code.zip”和描述中的信息都指向了一个概念——自动生成代码(Self-generating code)。在IT行业中,自动生成代码是指通过自动化工具、模板或者编程语言特性,根据预定义的规则或模型,自动...

    Generating Sequences With Recurrent Neural Networks(英文原版)

    一篇较好的描述seq2seq模式的英文资料。...works can be used to generate complex sequences with long-range struc- ture, simply by predicting one data point at a time. The approach is demonstrated for text ...

    Deep Visual-Semantic Alignments for Generating Image Descriptions

    We present a model that generates natural language descriptions of images and their regions. Our approach leverages datasets of images and their sentence descriptions to learn about the inter-modal ...

    Planar Metasurface for Vortex Beam Generating and Converging

    single-layer transmission-type metasurfaces are proposed to generate a converged vortex beam and vortex beams with different topological charges. A new metasurface design is used to generate the ...

    Generating Word Reports _ Documentssrc1

    标题 "Generating Word Reports _ Documentssrc1" 暗示我们关注的是如何在编程环境中生成Word文档报告。在这个场景中,我们可能涉及到的技术包括自动化文档生成、文本处理、模板设计和编程库的使用。通常,这会用到...

    WC Yeh-universal generating MPs

    ### WC Yeh-universal generating MPs #### 概述 该文章由IEEE Transactions on Systems, Man, and Cybernetics—Part A: Systems and Humans在2009年11月发表,作者Wei-Chang Yeh(IEEE高级会员)提出了一种简单...

    generating sounds

    using the processing(http://processing.org/) to generating the single sounds, like sin tiangle sounds and so on. after generating , add them as a wav file.

    GeST_ An Automatic Framework For Generating CPU Stress-Tests.pdf

    IEEE论文,利用基因算法做CPU压力测试,可以用来评估power和IPC。改论文用python实现了基因算法的框架,适用于X86 和 ARM。代码已经开源。

Global site tag (gtag.js) - Google Analytics