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

您给讲下题目意思吧,没看懂

Posted by 4Meal at 2006-07-06 21:34:52 on Problem 2869
In Reply To:帮忙看看我的构造哪里不对 Posted by:daringQQ at 2006-07-06 21:24:38
> 	while (scanf("%d", &n), n)
> 	{
> 		memset(flag, 0, sizeof(flag));
> 		for (i = 1; i <= n; i++)
> 		{
> 			scanf("%d", &a[i]);
> 			flag[a[i]] = 1;
> 		}
> 		for (i = 1; i <= n; i++)
> 			if (!flag[i]) 
> 			{
> 				printf("No solution\n");
> 				break;
> 			}
> 		if (i <= n) continue;
> 		top = 0;
> 		for (i = 1; i <= n; i++)
> 			for (j = i; j <= n; j++)
> 				if (a[j] == i)
> 				{
> 					for (k = j; k > i; k--)
> 					{
> 						s[top++] = k-1;
> 						a[k] = a[k-1];
> 					}
> 					a[i] = i;
> 					break;
> 				}
> 		printf("%d", top);
> 		while (top)
> 		{
> 			printf(" %d", s[--top]);
> 		}
> 		printf("\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