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 TSERROF at 2012-09-04 12:33:45 on Problem 1068
#include <cstdio>
#include <cstring>
#include <iostream>
int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		int N;
		scanf("%d",&N);
		char *s=new char[2*N+1];
		for(int i=0;i!=2*N;++i)s[i]=')';
		s[2*N]=0;
		int pre;
		scanf("%d",&pre);
		int pos=pre;
		for(int i=0;i!=pre;++i)s[i]='(';
		for(int i=1;i!=N;++i)
		{
			int now;
			scanf("%d",&now);		
			for(int j=0;j<now-pre;++j,++pos)s[pos+1]='(';
			++pos;
			pre=now;
		}
		int count=1;
		for(int i=0;i<2*N;++i)
		{
			while(i<2*N && s[i]==')')
			{
				int cnt=1;
				int j=i-1;
				while(j>=0 && s[j]!='(')
				{
					if(s[j]=='5')++cnt;
					--j;
				}
				s[j]='5';	
				if(count>1)printf(" ");
				++count;
				printf("%d",cnt);
				++i;
			}
		}
		printf("\n");
		delete[]s;
	}
	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