uva10098-fast generation of ordered permutations

Source: Internet
Author: User

This is a training reference for the solution of small petition violence

Topic Link http://acm.hust.edu.cn/vjudge/problem/19832

Thinking of solving problems

In the small white Book of the generation arrangement of the program, there may be elements to repeat.

Code

#include <stdio.h>#include<string.h>#include<algorithm>using namespacestd;Const intMaxLen = the;CharP[maxlen];voidPrint_permutation (intNChar*a,intcur) {    if(cur = = N) {A[cur] =' /'; printf"%s\n", a); }     for(intI=0; i<=n; i++)if(!i | | p[i]!=p[i-1]) {        intc1=0, c2=0;  for(intj=0; j<cur; J + +)if(A[j]==p[i]) c1++;  for(intj=0; j<n; J + +)if(P[j]==p[i]) c2++; if(c1<C2) {A[cur]=P[i]; Print_permutation (n, a, cur+1); }    }}intMain () {intN; scanf ("%d", &N);  for(intI=0; i<n; i++) {        CharA[maxlen]; scanf ("%s", p); Sort (p, p+strlen (p)); Print_permutation (Strlen (p), A,0); printf ("\ n"); }    return 0;}

uva10098-fast generation of ordered permutations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.