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 wangke at 2007-08-18 15:56:21 on Problem 3282
#include<iostream.h>
#include<string.h>
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int l,m;
		cin>>l>>m;
		l*=100;
		int *len=new int[m];
		char (*d)[6]=new char[m][6];
		for(int j=0;j<m;j++)
		{
			cin>>len[j]>>d[j];
		}
		int s=0,s1=0;
		if(strcmp(d[0],"right")==0)
		{
			s++;
		}
		for(j=0;j<m;j++)
		{
			s1+=len[j];
			if(j==m-1)
			{
				if(s1==0)
				{
					if(strcmp(d[j],d[j-1])==0)
					{
						s+=2;
						break;
					}
					else 
					{
						s++;
						break;
					}
				}
				else 
				{
					s++;
					break;
				}
			}
			if(s1+len[j+1]<=l&&strcmp(d[j],d[j+1])==0)
			{
				continue;
			}
			if(s1+len[j+1]<=l&&strcmp(d[j],d[j+1])!=0)
			{
				s++;
				s1=0;
			}
			if(s1+len[j+1]>l&&strcmp(d[j],d[j+1])!=0)
			{
				s++;
				s1=0;
			}
			if(s1+len[j+1]>l&&strcmp(d[j],d[j+1])==0)
			{
				s+=2;
				s1=0;
			}
			
		}
		cout<<s<<endl;
	}
	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