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

WHY I Get CE??????????????? NEED HELP!!!!!!!!!!!!!!!
Posted by Ural_Happy New Year! 19 Apr 2003 20:01
I can run in my delphi6 but CE here!!!!!!!!!
The judge system must see it
----------------------------------------------------
program Project2;

{$APPTYPE CONSOLE}

const setchar=['(',')','=','+','-','*','/','0'..'9','*'];
var i,j,pp,n,k:longint;
    ch:char;
    str:array[0..10000] of char;
    t:boolean;
begin
     i:=0;
     while not eof do begin read(ch); inc(i); str[i]:=ch; end;
     n:=i; i:=0;
     repeat
         inc(i);
         j:=i;
         if str[i]='(' then
            if str[i+1]='*' then
               begin
                    t:=false;
                    for j:=i+2 to n do if (str[j]='*')and(str[j+1]
=')') then
                        t:=true;
                    if t=false then begin writeln('NO'); halt; end
                       else i:=j+2;
                    j:=0;
               end
            else begin
                 pp:=1;
                 repeat
                       inc(j);
                       if str[j] in setchar then begin end
                          else begin writeln('NO'); halt; end;
                       if (str[j]='*')and(str[j-1]='(') then
                          begin
                          dec(pp);
                          for k:=j to n do
                              if (str[k]='*')and(str[k+1]=')') then
                                 begin
                                      j:=k+2;
                                      break;
                                 end;
                          if k>=n then begin writeln('NO'); halt; end;
                          end;
                       if str[j]=')' then dec(pp);
                       if pp=0 then break;
                       if str[j]='(' then inc(pp);
                 until j>=n;
                 if pp<>0 then begin writeln('NO'); halt; end;
                 i:=j+1;
                 end;
     until i>=n;
     writeln('YES');
     readln;
end.
Submit it via E-mail and you can where's error. Read the FAQ if you don't know how (-)
Posted by MadPsyentist/Sam 21 Apr 2003 03:54
My English is poor, can you say a little clearly
Posted by Ural_Happy New Year! 21 Apr 2003 17:18
>
when u choose "reply to my e-mail",Judge will tell u why it's get ce(-)
Posted by TheBlaNK 22 Apr 2003 08:41
> >
Thanks, and I know where CE. But I got WA. Please Help
Posted by Ural_Happy New Year! 22 Apr 2003 14:50
Here is my cole

program t1027;
{const fin='f:\temp\in4.txt';}
var i,j,pp,n,k:longint;
    ch:string;
    str:array[1..10000] of char;
    t:boolean;
begin
{     assign(input,fin);
     reset(input);}
     j:=1;
     while not eof do
           begin
           readln(ch);
           for i:=1 to length(ch) do
           begin str[j]:=ch[i]; inc(j); end;
           end;
     n:=j; i:=0;
     repeat
         inc(i);
         j:=i;
         if str[i]='(' then
            if str[i+1]='*' then
               begin
                    t:=false;
                    for j:=i+2 to n do if (str[j]='*')and(str[j+1]
=')') then
                        t:=true;
                    if t=false then begin writeln('NO'); halt; end
                       else i:=j+2;
                    j:=0;
               end
            else begin
                 pp:=1;
                 repeat
                       inc(j);
                       if not(str[j] in ['(',')','0'..'9','+','-
','*','/','='])
                          then begin writeln('NO'); halt; end;
                       if (str[j]='*')and(str[j-1]='(') then
                          begin
                          dec(pp);
                          for k:=j+1 to n do
                              if (str[k]='*')and(str[k+1]=')') then
                                 begin j:=k+2; break; end;
                          if k>=n then begin writeln('NO'); halt; end;
                          end;
                       if str[j]=')' then dec(pp);
                       if pp=0 then break;
                       if str[j]='(' then inc(pp);
                 until j>=n;
                 if pp<>0 then begin writeln('NO'); halt; end;
                 i:=j+1;
                 end;
     until i>=n;
     writeln('YES');
{     close(input);}
end.
Re: Thanks, and I know where CE. But I got WA. Please Help
Posted by TheBlaNK 23 Apr 2003 19:56
compile my code
and test ur prog :)
i think this prob description is not clear


#include <stdio.h>
#include <ctype.h>
FILE *fp,*fx;
int main()
{
 long false,com=0,sum=0;
 char kao,chr;
 fp=stdin; fx=stdout;
// fp=fopen("1027.in","r"); fx=fopen("1027.out","w");
 false=0;
 kao=0;
  while(fscanf(fp,"%c",&chr)!=EOF)
   {
    if(com&&chr==')'&&kao=='*') com=0;
    else if(!com&&chr==')'&&kao=='*'&&!sum) false=1;
    else if(!com&&chr==')'&&kao=='*'&&sum) sum--;
    else if(!com)
      {
     if(chr=='(') sum++;
     else if(chr=='*'&&kao=='(') { sum--; com=1; chr=0; }
     else if(chr==')') sum--;
     else if(sum>0&&!(isdigit(chr)
||chr=='\r'||chr=='\n'||chr=='='||chr=='+'||chr=='-
'||chr=='*'||chr=='/'))
      false=1;
      }
    if(false||sum<0) break;
    kao=chr;
   }
  if(false||sum>0||sum<0||com) fprintf(fx,"NO\n");
  else fprintf(fx,"YES\n");
// fclose(fp); fclose(fx);
 return 0;
}
Thank you anyway.But I didn't know C or C++
Posted by Ural_Happy New Year! 24 Apr 2003 12:13
If you can test my cole and find my bugs, thanks a lot.
Mail me Walter_ddr@hotmail.com