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

test for AC
Posted by VietDung_CNT46DH_VIMARU 18 May 2006 10:22
(*(*) what is your idea about this?
Re: test for AC
Posted by xakac [BMSTU] 6 Aug 2006 08:08
YES
WA#10
Posted by Zubyk Taras 6 Aug 2006 15:11
Give me some tests! I can't find my mistake.
See my prog:

Const s='=+-*/0123456789)(';
VAR k1,k2,i,p,r :longint;
    ch          :char;
Procedure KOMEN(var ch:char);
begin
  inc(k2);
  while (not (eof))and(k2<>0) do begin
    read(ch);
    while ch='*' do begin
      read(ch);
      while (ch<#27) do read(ch);
        if ch=')' then begin dec(k2); break end;
    end;
  end;
end;
BEGIN
  r:=0;
  while not (eof) do begin
    if r=0 then read(ch) else r:=0;
    if ch='(' then begin
        read(ch);
        while (ch<#27)and(not (eof)) do read(ch);
        if ch='*' then begin KOMEN(ch); if eof then break;
      end else begin
            inc(k1);
            if ch=')' then dec(k1); p:=0;
            if ch='(' then inc(k1);
            for i:=1 to 17 do
                if ch=s[i] then begin p:=1; break; end;
            if p=0 then begin writeln('NO'); halt end;
            while (not (eof))and(k1<>0) do begin
              read(ch); p:=0;
              if ch<#27 then continue;
              for i:=1 to 17 do
                if ch=s[i] then begin p:=1; break; end;
              if p=0 then begin writeln('NO'); halt end;
              if ch='(' then begin
                read(ch);
                while (ch<#27)and(not (eof)) do read(ch);
                if ch='*' then begin KOMEN(ch); if eof then break; end
                  else begin
                    inc(k1); p:=0;
                    for i:=1 to 17 do
                      if ch=s[i] then begin p:=1; break; end;
                    if p=0 then begin writeln('NO'); halt end;
                    if ch=')' then dec(k1);
                    if ch='(' then inc(k1);
                  end;
              end else if ch=')' then begin dec(k1); if k1=0 then break end;
            end;
            if eof then break;
          end;
    end else if ch='*' then begin
          read(ch); r:=1;
          while (ch<#27)and(not (eof)) do read(ch);
          if ch=')' then begin dec(k2); if k2<0 then break; end;
        end else if ch=')' then begin r:=1; dec(k1); if k1<0 then break; end;
  end;
  if (k1<>0)or(k2<>0) then writeln('NO') else writeln('YES');
END.

Help me please! Thanks, very mach!

P.S. Sory for my English