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 scau200930760204 at 2010-07-16 00:24:21 on Problem 3051
#include<stdio.h>
int js[80*1000],c[80*1000];
int main()
{
   int i,j,k,m,n,f=0,s1,s2;
   char s[80];
    for(i=0;i<80*1000;i++)
    c[i]=-1;
    scanf("%d %d",&n,&m);fflush(stdin);
    gets(s) ;
    for(j=0;j<n;j++)
    {
        if(s[j]=='*')
        {
            if(f==0)
           { c[j]=j;js[j]++;f=1;   }
           else{
            c[j]=c[j-1]; js[c[j]]++;}
        }
        else
        f=0;
    }
    for(i=1;i<m;i++)
    {
        gets(s);f=0;
        for(j=0;j<n;j++)
        {
            k=80*i+j;
            if(s[j]=='*'){
                if(f==0){
                if(c[k-80]==-1)
                 { c[k]=k; js[k]++;f=1;}
                else{
                    s1=c[k-80];  c[k]=s1;
                    while(s1!=c[s1])
                    s1=c[s1];
                    js[s1]++; f=1;
                }
                }
                else{      /*f=1*/
                    if(c[k-80]==-1)
                         { c[k]=c[k-1]; js[c[k]]++;}
                    else{
                        s1=c[k-1];s2=c[k-80];
                     while(s1!=c[s1])  s1=c[s1];
                     while(s2!=c[s2])  s2=c[s2];
                     if(s1==s2){
                        c[k]=s2;js[s2]++ ;
                     }
                     else{
                         c[k]=s2;c[s1]=s2;js[s2]+=js[s1]+1 ;
                     }
                    }
                }
            } /*end if(s[j]=='*') */
              else f=0;
        }
    }
            for(i=0,j=0;i<80*m+n;i++)
                if(js[i]>j)j=js[i];
                 printf("%d",j);
                 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