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

是不是有特殊情况?为什么一直WA?麻烦哪位高手有空帮忙看看哈,谢咯~(附代码)

Posted by acm_pku at 2007-07-25 09:58:53 on Problem 3282
#include "stdio.h"
#include "string.h"
struct car
{
	int length;
	char s[6];
};
int main()
{
	int l,m,i,count,k,curlen,n,j;
	scanf("%d",&n);
	for(j=1;j<=n;j++)
	{
	scanf("%d%d",&l,&m);
	struct car *a=new struct car[m];
	for(i=0;i<m;i++)
	{
		scanf("%d%s",&a[i].length,a[i].s);
	}
	count=0;
    if(strcmp(a[0].s,"right")==0)
		count=1;
    curlen=a[0].length;
	i=1;
	k=0;
	while(i<m)
	{
		if(strcmp(a[k].s,a[i].s)==0)
		{
			curlen=curlen+a[i].length;
			if(curlen>l*100)
			{
				count=count+2;
				curlen=a[i].length;
				k=i;
			}
		}
		else
		{
			count=count+1;
			k=i;
			curlen=a[i].length;
			
		}
		i++;
	}
	printf("%d\n",count+1);
	}
	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