| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
莫名地 一次AC 了,没用搜索,直接记录S中向左凸的个数,只是效率很低。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator