Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:next_permutation() 好使。。。水过

Posted by jxufe_jp at 2012-07-23 19:26:20 on Problem 1833
In Reply To:next_permutation() 好使。。。水过 Posted by:zihuacs at 2010-08-18 22:52:22
我也用了,但是超时啊!!
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n1,n,k,i,j,a[1024];
    cin>>n1;
    while(n1--)
    {
        cin>>n>>k;
        for(i=0;i<n;i++,j++)
        {
            cin>>j;
            a[i]=j;
        }
       for(i=0;i<k;i++)
        next_permutation(a,a+n);
        for(i=0;i<n;i++)
          cout<<a[i]<<' ';
          cout<<endl;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator