讨论 / 250
余可2代 2011-04-22 04:35:00
点我顶贴 收藏 删除
250~~
#1 张湛二代@2011-04-20 21:14:00
回复 删除
program dasx;

var x,i,j,k,m,n,z,qire:longint; f:boolean;

ss,s1:ansistring; h:char; sss:ansistring;

s:array[1..5000] of string;

function run(s:string):integer;

var i,j,code:integer; ss:string;

begin

ss:=copy(s,2,length(s)-2);

val(ss,i,code);

run:=i;

end;

begin

j:=0; i:=0;

while (not eoln(input)) do

begin

read(h);

if (h='[') or (h='{') then

begin

inc(j);

repeat

s[j]:=s[j]+h;

read(h);

until (h=']') or (h='}');

s[j]:=s[j]+h;

end

else begin inc(j); s[j]:=s[j]+h; end;

end;

readln;

while (not eof(input)) do

begin

readln(ss); f:=true;

x:=1;

for i:=1 to j do

begin

if (s[i]='[')

then

begin

sss:=copy(s[i],2,length(s[i])-2);

if pos('-',sss)<>0 then

begin

s1:='';

repeat

for m:=ord(sss[pos('-',sss)-1])+1 to ord(sss[pos('-',sss)+1])-1 do

s1:=s1+chr(m);

insert(s1,sss,pos('-',sss));

delete(sss,pos('-',sss),1);

until pos('-',sss)=0;

end;

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],sss)=0 then f:=false;

x:=x+k;

end

else

if s[i][1]<>'{' then

begin

sss:=s[i];

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],ss)=0 then f:=false;

x:=x+k;

end;

end;

if x<>length(ss)+1 then f:=false;

if f then writeln('Regular Expression is Fun!') else

writeln('Boring String Matching...');

end;

end.

#2 张湛二代@2011-04-20 21:15:00
回复 删除
program dasx;

var x,i,j,k,m,n,z,qire:longint; f:boolean;

ss,s1:ansistring; h:char; sss:ansistring;

s:array[1..5000] of string;

function run(s:string):integer;

var i,j,code:integer; ss:string;

begin

ss:=copy(s,2,length(s)-2);

val(ss,i,code);

run:=i;

end;

begin

j:=0; i:=0;

while (not eoln(input)) do

begin

read(h);

if (h='[') or (h='{') then

begin

inc(j);

repeat

s[j]:=s[j]+h;

read(h);

until (h=']') or (h='}');

s[j]:=s[j]+h;

end

else begin inc(j); s[j]:=s[j]+h; end;

end;

readln;

while (not eof(input)) do

begin

readln(ss); f:=true;

x:=1;

for i:=1 to j do

begin

if (s[i]='[')

then

begin

sss:=copy(s[i],2,length(s[i])-2);

if pos('-',sss)<>0 then

begin

s1:='';

repeat

for m:=ord(sss[pos('-',sss)-1])+1 to ord(sss[pos('-',sss)+1])-1 do

s1:=s1+chr(m);

insert(s1,sss,pos('-',sss));

delete(sss,pos('-',sss),1);

until pos('-',sss)=0;

end;

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],sss)=0 then f:=false;

x:=x+k;

end

else

if s[i][1]<>'{' then

begin

sss:=s[i];

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],ss)=0 then f:=false;

x:=x+k;

end;

end;

if x<>length(ss)+1 then f:=false;

if f then writeln('Regular Expression is Fun!') else

writeln('Boring String Matching...');

end;

end.

#3 蝌蚪@2011-04-22 04:32:00
回复 删除
11

11

#4 蛤蛤@2011-04-22 04:35:00
回复 删除
250解

program dasx;

var x,i,j,k,m,n,z,qire:longint; f:boolean;

ss,s1:ansistring; h:char; sss:ansistring;

s:array[1..5000] of string;

function run(s:string):integer;

var i,j,code:integer; ss:string;

begin

ss:=copy(s,2,length(s)-2);

val(ss,i,code);

run:=i;

end;

begin

j:=0; i:=0;

while (not eoln(input)) do

begin

read(h);

if (h='[') or (h='{') then

begin

inc(j);

repeat

s[j]:=s[j]+h;

read(h);

until (h=']') or (h='}');

s[j]:=s[j]+h;

end

else begin inc(j); s[j]:=s[j]+h; end;

end;

readln;

while (not eof(input)) do

begin

readln(ss); f:=true;

x:=1;

for i:=1 to j do

begin

if (s[i]='[')

then

begin

sss:=copy(s[i],2,length(s[i])-2);

if pos('-',sss)<>0 then

begin

s1:='';

repeat

for m:=ord(sss[pos('-',sss)-1])+1 to ord(sss[pos('-',sss)+1])-1 do

s1:=s1+chr(m);

insert(s1,sss,pos('-',sss));

delete(sss,pos('-',sss),1);

until pos('-',sss)=0;

end;

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],sss)=0 then f:=false;

x:=x+k;

end

else

if s[i][1]<>'{' then

begin

sss:=s[i];

k:=1;

if s[i+1][1]='{' then k:=run(s[i+1]);

for z:=x to x+k-1 do

if pos(ss[z],ss)=0 then f:=false;

x:=x+k;

end;

end;

if x<>length(ss)+1 then f:=false;

if f then writeln('Regular Expression is Fun!') else

writeln('Boring String Matching...');

end;

end.

查看更多回复
提交回复