p党求助,为什么只有40分?

P2024 [NOI2001] 食物链

修改后的精简代码(删去了程序而已) ```pascal var last,next:array[1..3] of longint; flag:array[0..50005] of boolean; z,yy,ans,n,k,i,x,zz,y:longint; f:array[0..50005] of longint; begin read(n,k); for i:=1 to 2 do next[i]:=i+1;next[3]:=1; for i:=2 to 3 do last[i]:=i-1;last[1]:=3; for i:=1 to k do begin read(x,y,z); if (y>n) or (y<1) or (z>n) or (z<1) then inc(ans) else begin if x=1 then begin if (flag[y] and flag[z]) and (f[y]<>f[z]) then inc(ans); if flag[y] and not flag[z] then begin f[z]:=f[y];flag[z]:=true; end; if flag[z] and not flag[y] then begin f[y]:=f[z];flag[y]:=true; end; if (not flag[y]) and (not flag[z]) then begin f[y]:=1;f[z]:=1;flag[y]:=true;flag[z]:=true; end; end; if x=2 then begin if (flag[y] and flag[z]) and (next[f[y]]<>f[z]) then inc(ans); if flag[y] and not flag[z] then begin f[z]:=next[f[y]];flag[z]:=true; end; if flag[z] and not flag[y] then begin f[y]:=last[f[z]];flag[y]:=true; end; if (not flag[z]) and (not flag[y]) then begin f[y]:=1;f[z]:=2;flag[y]:=true;flag[z]:=true; end; end; end; end; writeln(ans); end. ``` 求助啊,为什么只有40分,我觉得思路很清晰啊,应该没有什么大方面的错误。
by hwhwh @ 2018-10-07 18:41:15


|