language: Pascal (fpc) (fpc 2.2.0)
date: 105 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var s:string;
    stack:array[0..240] of char;
    i,j,n,e:longint;
    no:boolean;
Begin
Assign(input,'input.txt');
reset(input);
Assign(output,'output.txt');
rewrite(output);
readln(s);
for i:=1 to length(s) do
 if (s[i]='(') or (s[i]='{') or (s[i]='[') then
  begin
   inc(e);
    if s[i]='(' then stack[e]:=')' else
     if s[i]='{' then stack[e]:='}' else stack[e]:=']';
  end else
   if (stack[e]<>s[i]) then no:=true else dec(e);
if (e<>0) or (no) then write('Нет') else write('Да');
end.