ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1027. D++ Again

WA26
Posted by Gelioscope 25 Jun 2011 11:42
This is my code:
#include <stdio.h>
#include <string.h>
#define ulong unsigned long
void main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","rt",stdin);
    freopen("out.txt","wt",stdout);
#endif
    bool comment=0,arithmetical=0;
    long brakets=0;
    char syms[10001];
    ulong i=0;
    while(fgets(syms+i,10000,stdin))
    {
        i=strlen(syms)-1;
    }
    for(i=0;i<strlen(syms);++i)
    {
        if(comment)
        {
            for(;i<strlen(syms);++i)
                if(syms[i]=='*'&&syms[i+1]==')')
                {
                    ++i;
                    comment=0;
                    break;
                }
            continue;
        }
        if(arithmetical)
        {
            for(;i<strlen(syms);++i)
            {
                if(!((syms[i]>=0x28&&syms[i]<=0x2B)||(syms[i]>=0x30&&syms[i]<=0x39)||syms[i]=='-'||syms[i]=='/'||syms[i]=='='))
                {
                    printf("NO");
                    return;
                }
                if(syms[i]=='(')
                {
                    if(syms[i+1]=='*')
                    {
                        ++i;
                        comment=1;
                        break;
                    }
                    ++brakets;
                }
                if(syms[i]==')')
                {
                    --brakets;
                    if(!brakets)
                    {
                        arithmetical=0;
                        break;
                    }
                }
            }
            continue;
        }
        for(;i<strlen(syms);++i)
        {
            if(syms[i]=='(')
            {
                if(syms[i+1]=='*')
                {
                    ++i;
                    comment=1;
                    break;
                }
                ++brakets;
                arithmetical=1;
                break;
            }
            if(syms[i]==')')
            {
                printf("NO");
                return;
            }
        }
    }
    if(comment||arithmetical)
    {
        printf("NO");
        return;
    }
    printf("YES");
}
why wa 26?
Re: WA26
Posted by Gelioscope 25 Jun 2011 12:10
(*(**)*) must be "YES" or "NO"?
Re: WA26
Posted by Gelioscope 25 Jun 2011 17:23
must be "NO". i find the mistake.it seems, test contains the limit of text in one line.

Edited by author 25.06.2011 17:34

Edited by author 25.06.2011 17:35