|
|
back to board++I submit program 20 times, but I get WA! Please help me or give some tests!++ I submit my program 20 times but I still get WA? The problem is so simple but... I tried all tests written in the forum my program gives correct answer. var a:array[1..10001] of char; ch:char; n:integer; skobka,comm:boolean; nsk:integer; i:integer; procedure readdata; begin n:=0; while not eof do begin inc(n); read(ch); a[n]:=ch; end; end; function check(ch:char):boolean; begin if (ch in ['0'..'9']) or (ch in ['=','+','-','*','/']) then check:=true else check:=false; end; begin readdata; skobka:=false; comm:=false; for i:=1 to n do if (comm) and (a[i]='*') and (a[i+1]=')') then begin comm:=false; inc(i); end else if (not comm) and (a[i]='(') and (a[i+1]='*') then begin comm:=true; inc(i); end else if comm then begin end else if (not skobka) and (a[i]='(') then begin skobka:=true; nsk:=1; end else if (skobka) and (a[i]=')') then begin dec(nsk); if nsk=0 then begin skobka:=false; nsk:=-maxint; end; end else if (skobka) and (a[i]='(') then begin inc(nsk); end else if ((skobka) and (not check(a[i]))) or ( (not skobka) and (a[i]='*') and (a[i+1]=')') and (not comm)) then begin writeln('NO'); halt; end else if (nsk<0) and (nsk<>-maxint)then begin writeln('NO'); halt; end; if (comm) or (skobka) then writeln('NO') else writeln('YES'); end. Re: ++I submit program 20 times, but I get WA! Please help me or give some tests!++ On sample input yours outputs NO, correct is YES... Re: ++I submit program 20 times, but I get WA! Please help me or give some tests!++ No, you are mistaken on sample test my program gives correct answer(YES)! |
|
|