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

Re:帮忙找错的测试数据!我是在是找不出来。感觉不应该WA……

Posted by sunnyboy1001 at 2007-12-30 17:38:53 on Problem 3476
In Reply To:Re:帮忙找错的测试数据!我是在是找不出来。感觉不应该WA…… Posted by:sunnyboy1001 at 2007-12-30 17:37:41
我也是,感觉不该wa,c语言
#include<stdio.h>

int main(void){
   char a[1000005][2],ch;
   int i,num,m,m0,m1,left,right;
   
   scanf("%c",&ch);
   a[i][0]=ch;
   a[i][1]=1;
   scanf("%c",&ch);
   for(i=1;ch!='\n';i++){
      a[i][0]=ch;
      if(ch==a[i-1][0])
         a[i][1]=a[i-1][1]+1;
      else
         a[i][1]=1;
      scanf("%c",&ch);
   }
   num=--i;
   for(m=0;i>=0;i--)
      if(m<=a[i][1]){
         m=a[i][1];
         m1=i;
      }   
   m0=m1-m+1;
   while(m>1){
      printf("%c",a[m0][0]);
      for(i=m0;i<=m1;i++)
         if(a[i][1]!=0){
            printf(" %d",i+1);
            a[i][1]=0;
         }   
      printf("\n");
      
      m=0;
      for(left=m0-1;left>=0&&a[left][1]==0;left--);
      if(left>=0){
         for(right=m1+1;right<=num&&a[right][1]==0;right++);
         if(right<=num&&a[left][0]==a[right][0]){
            m=a[left][1];
            a[right][1]=++m;
            for(i=right+1;i<=num&&a[i][1]!=1;i++)
               if(a[i][1]!=0)
                  a[i][1]=++m;
         }   
      }   
      
      for(i=num;i>=0;i--){
         if(m<=a[i][1]){
            m=a[i][1];
            m1=i;
            m0=-1;
         }
         if(m0==-1&&a[i][1]==1)
            m0=i;   
      }   
   }   
   
   system("pause");
   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