JZOJ4840 小W砍大树

来源:互联网 发布:淘宝上怎样能买到春药 编辑:程序博客网 时间:2024/04/28 01:56

就是超级暴力大模拟,比赛时候莫名其妙打错了。。

var        i,j,k,p,n,m,tot:longint;        s:ansistring;        b:array[0..40000]of boolean;begin        assign(input,'form.in');        assign(output,'form.out');        reset(input);        rewrite(output);         p:=0;        while true do        begin                readln(s);                if s='' then break;                n:=length(s);                inc(p);                b[0]:=false;                tot:=0;                for i:=1 to n do                begin                        if s[i]='(' then                        begin                                inc(tot);                                if tot and 1<>0 then                                b[tot]:=true                                else b[tot]:=false;                        end                        else                        if s[i]=')' then                        begin                                if tot and 1<>0 then                                b[tot-1]:=b[tot-1] or b[tot]                                else b[tot-1]:=b[tot-1]and b[tot];                                dec(tot);                        end                        else                        if s[i]='F' THEN                        begin                                if tot mod 2<>0 then b[tot]:=false;                        end                        else if tot mod 2=0 then b[tot]:=true;                end;                if b[0] then writeln(p,'. true')                else writeln(p,'. false');        end;end.
0 0
原创粉丝点击