讨论 / 没过样例1,AC了,为什么????????????
宇轩 2012-12-08 03:54:00
点我顶贴 收藏 删除
状态: Accepted

测评机: Xeost[5]

得分: 100分 [我要评价一下题目~]

提交日期: 2012-7-13 11:39:00

有效耗时: 2546毫秒

测试结果1: 通过本测试点|有效耗时187ms

测试结果2: 通过本测试点|有效耗时63ms

测试结果3: 通过本测试点|有效耗时156ms

测试结果4: 通过本测试点|有效耗时172ms

测试结果5: 通过本测试点|有效耗时172ms

测试结果6: 通过本测试点|有效耗时203ms

测试结果7: 通过本测试点|有效耗时203ms

测试结果8: 通过本测试点|有效耗时484ms

测试结果9: 通过本测试点|有效耗时406ms

测试结果10: 通过本测试点|有效耗时500ms

提交代码: view sourceprint?

program yx;

var i,j,k,l,t:longint;

s,p,z,x,s1:ansistring;

begin

readln(s1);

readln(s);

for i:=1 to length(s1) do

s1[i]:=upcase(s1[i]);

for i:=1 to length(s) do

s[i]:=upcase(s[i]);

k:=length(s1);

for i:=1 to length(s) do

if(copy(s,i,k)=s1)and(s[i+k]=' ')and(s[i-1]=' ') then

inc(t);

for i:=1 to length(s) do

if(copy(s,i,k)=s1)and(s[i+k]=' ')and(s[i-1]=' ') then

begin

l:=i;

break;

end;

{ p:='';

for i:=1 to length(s) do

if s[i]<>' ' then p:=p+s[i]

else

begin

if p=s1 then inc(t);

p:='';

end;}

if t=0 then

write('-1')

else

write(t,' ',l-1);

end.

end.

#1 lzn@2012-07-31 19:53:00
回复 删除
字符串数组下标越界

for i:=1 to length(s) do

if(copy(s,i,k)=s1)and(s[i+k]=' ')and(s[i-1]=' ') then

i-1 和i+k 会越界啊

rq评测环境可能会忽略这些运行错误,就A了

应该是 for i:=1 to length(s)-k+1 do

if(copy(s,i,k)=s1)and((i+k=length(s)+1)or(s[i+k]=' '))and((I=1)or(s[i-1]=' ')) then

#2 404510@2012-12-08 03:54:00
回复 删除
大写不算

你的程序没包括大写;

例题里包括了大写;

可能是例题有错误

查看更多回复
提交回复