fork download
  1. var s:string;
  2. stack:array[0..240] of char;
  3. i,j,n,e:longint;
  4. no:boolean;
  5. Begin
  6. Assign(input,'input.txt');
  7. reset(input);
  8. Assign(output,'output.txt');
  9. rewrite(output);
  10. readln(s);
  11. for i:=1 to length(s) do
  12. if (s[i]='(') or (s[i]='{') or (s[i]='[') then
  13. begin
  14. inc(e);
  15. if s[i]='(' then stack[e]:=')' else
  16. if s[i]='{' then stack[e]:='}' else stack[e]:=']';
  17. end else
  18. if (stack[e]<>s[i]) then no:=true else dec(e);
  19. if (e<>0) or (no) then write('Нет') else write('Да');
  20. end.
Runtime error #stdin #stdout 0.01s 4112KB
stdin
Standard input is empty
stdout
Standard output is empty