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

Why WA????

Posted by caizhicong0503 at 2007-02-17 23:27:42 on Problem 1833
#include<iostream>
#include<algorithm> 
using namespace std; 
int d[1024]; 
int main()
{
	int i,N,n,k,s;
	scanf("%d",&N); 
	while(N--)
	{ 
		scanf("%d %d",&n,&k); 
		for(i=0;i<n;i++)	scanf("%d",&d[i]); 
		s=0; 
		do
		{
			for(i=0;i<n;i++)	
				if(d[i]!=(n-i))	break;
			if(i==n)
			{
				for(i=0;i<n;i++)	d[i]=i+1; 
				s++;
			} 
			if(s==k)
			{
				for(i=0;i<n;i++)	printf("%d ",d[i]); 
				printf("\n"); 
				break; 
			}
			s++;
		}while(next_permutation(d,d+n)); 
	} 
} 

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