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

莫名地 一次AC 了,没用搜索,直接记录S中向左凸的个数,只是效率很低。

Posted by Dream_Learner at 2010-08-20 16:22:32 on Problem 2056
#include <iostream>
using namespace std;

char s[202];
int pos[202];

int main()
{
	int M,N,i,j;
	while(scanf("%d%d",&N,&M)!=EOF&&M&&N)
	{
		int sum_S=0,mark=0;
		for(i=1;i<=N;i++)
		{
			mark=0;
			scanf("%s",s);
			for(j=M-1;j>=0;j--)
				if(s[j]=='S')
				{
					sum_S++;
					if(mark==0)
					{
						pos[i]=j+1;
						mark=1;
					}
				}
		}
		int k=2,count=0,special=0;
		for(i=2;i<=N;i++)
		{
			if(pos[i]<pos[i-1])
				k=1;
			if(pos[i]>pos[i-1]&&k>=1)
			{
				if(k==2)
					special++;
				k=0;
				count++;

			}
			if(i==N&&k==1)
			{
				count++;
				special++;
			}
		}
		printf("%d\n",sum_S-count*2+special);
	}
	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