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

模拟一下马上就出来了!0ms哦!

Posted by chenxuan123456789 at 2012-08-04 18:20:06 on Problem 1068
#include <stdio.h>
int main()
{
	char s[100];
	int count1,count2,i,j,n,k,cases,c;
	scanf("%d",&cases);
	while(cases--)
	{
		scanf("%d",&n);
		scanf("%d",&i);
		for(j=0;j<i;j++)
		s[j]='(';
		s[j++]=')';
		n--;
		k=i;
		c=n;
		while(n--)
		{
			scanf("%d",&i);
			for(;k<i;k++)
             s[j++]='(';
			 s[j++]=')';
			 k=i;
		}
		s[j]='\0';
		//printf("%s\n",s);
		for(i=0;i<j;i++)
		{
			if(s[i]==')')
			{
				count1=1;
				count2=0;
				   for(k=i-1;k>=0;k--)
				   {
					   if(s[k]=='(')
							count2++;
						if(s[k]==')')
							count1++;
						if(count1==count2)
							break;
				   }
			if(c--)
			printf("%d ",count1);
			else
			printf("%d\n",count1);
			}
		}
	}
	return 1;
}
		



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