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 piaomiao1314 at 2013-05-19 13:52:08 on Problem 3974
#include<stdio.h>
#include<string.h>
#define MAXN 1000000 + 10
char s[MAXN];
int main()
{
    int cas=1,i,j,max,l;
    while(1)
    {
        gets(s);
        if(s[0]=='E') break;
        max=0;
        l=strlen(s);

        for(i=0; i<l; i++)
        {
            for(j=0; i-j>=0 && i+j<l; j++)
            {

                if(s[i-j]!=s[i+j]) break;
                if(2*j+1>max) max=2*j+1;
            }
            for(j=0; i-j>=0 && i+j+1<l; j++)
            {
                    if(s[i-j]!=s[i+j+1]) break;
                    if(2*j+2>max) max=2*j+2;
            }
        }
        printf("case %d: %d\n",cas++,max);
    }
    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