|
|
back to boardWhy I get WA? Pelase, help me!!!!!!! Gave me any hints!! (+) My program: Program t1078; Const MaxN=501; Type Seg=record l,r,Pred,Cur,Num :integer end; Var N,i,j :integer; L :array[1..MaxN]of Seg; Way :array[1..MaxN]of integer; Pred,C :integer; Max,Mi :integer; begin Read(N); for i:=1 to N do read(l[i].l,l[i].r); for i:=1 to N do l[i].num:=i; for i:=1 to MaxN do l[i].Pred:=-1; for i:=1 to MaxN do l[i].Cur:=1; for i:=1 to N-1 do for j:=i+1 to N do if l[i].l>l[j].l then begin l[MaxN]:=l[i]; l[i]:=l[j]; l[j]:=l[MaxN]; end else if (l[i].l=l[j].l)and(l[i].r<l[j].r) then begin l[MaxN]:=l[i]; l[i]:=l[j]; l[j]:=l[MaxN]; end; l[1].Pred:=0; for i:=2 to N do begin max:=1; mi:=0; for j:=1 to i-1 do if l[j].l<=l[i].l then if l[j].r>=l[i].r then if (l[j].l<l[i].l)or(l[j].r>l[i].r) then if l[j].cur+1>max then begin max:=l[j].cur+1; mi:=j; end; l[i].cur:=max; l[i].pred:=mi; end; Max:=0; for i:=1 to N do if l[i].cur>max then begin max:=l[i].cur; mi:=i; end; pred:=mi; c:=1; while pred<>0 do begin Way[c]:=l[pred].num; c:=c+1; pred:=l[pred].pred; end; Writeln(max); for i:=1 to max do write(way[i],' ');writeln; end. Re: Why I get WA? Pelase, help me!!!!!!! Gave me any hints!! (+) ... We assume, that one segment is inside another, if the two segments are different, the first one is fully contained in the second one, !!!!!!!and their endpoints do not coincide.!!!!!!! ... For the test: 2 2 7 2 5 Your program output 2 2 1 But right answer 1 1 Or 1 2 Good luck! Re: Thank you! You helped me great. I get AC. > ... > We assume, that one segment is inside another, if the two segments > are different, the first one is fully contained in the second one, > !!!!!!!and their endpoints do not coincide.!!!!!!! > ... > For the test: > 2 > 2 7 > 2 5 > > Your program output > 2 > 2 1 > > But right answer > 1 > 1 > Or > 1 > 2 > > Good luck! > > |
|
|