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 Wrong Answer?
Posted by Aidar 6 Feb 2002 01:02
{$IFDEF DEBUG}
Uses CalcTime, Debug;
{$ENDIF}
label a;
var
  STACKPos : word;
  STACK : array [1..10010] of set of (Skobki, Comment, Txt);
  c, cnext : char;

begin
  c := #0; STACKPos := 1;
  STACK [STACKPos] := [];
  repeat Read (cnext) until cnext > #13;
  while not (cnext = #26) do begin
    c := cnext;
    repeat Read (cnext) until cnext in [#26, #32..#255];
    if (c = '(') then begin
      Inc (STACKPos);
      if cnext = '*' then begin
        STACK [STACKPos] := [Comment];
      end else begin
        STACK [STACKPos] := [Skobki];
      end;
    end;
    if not
      (c in ['=', '+', '-', '*', '/',
             '0'..'9', '(', ')']) then begin
      Include (STACK [STACKPos], Txt);
    end;
    if (cnext = ')') then begin
      if ((c = '*') and (STACK [STACKPos] = [Comment, Txt])) or
        ((STACK [STACKPos] = [Comment]) or
        (STACK [STACKPos] = [Skobki])) then begin
          Dec (StackPos);
          if StackPos = 0 then goto a;
        end else if not (STACK [STACKPos] = [Comment, Txt]) then begin
a:        WriteLn ('NO');
          Halt;
        end;
    end;
  end;
  if (STACKPos = 1) {and (STACK [STACKPos] = [Txt])} then begin
    WriteLn ('YES');
  end else WriteLn ('NO');
end.
A test for you (+)
Posted by shitty.Mishka 6 Feb 2002 15:19
Try this test case:
(*)
The answer should be NO

Good luck!
Re: A test for you (+)
Posted by Aidar 9 Feb 2002 05:55
> Try this test case:
> (*)
> The answer should be NO
>
> Good luck!
Why No? (Because * is arithmetic expression)