|
|
back to boardWho can help me toAC? Posted by win_L 14 Jul 2011 13:50 Why WA? Just tree node, who have data? Please give me one. var n,i,j,k,count:integer; c,x,y,sum:array[1..15000]of integer; function lowbit(x:integer):integer; begin exit(x and (-x)); end; procedure increase(k:integer); var s:integer; begin s:=k; while s<n do begin inc(c[s]); s:=s+lowbit(s); end; end; function getsum(k:integer):integer; var s,t:integer; begin t:=0; s:=k; while s>0 do begin t:=t+c[s]; s:=s-lowbit(s); end; exit(t); end; begin fillchar(c,sizeof(c),0); readln(n); for i:=1 to n do begin readln(x[i],y[i]); count:=1; if i=1 then begin increase(1); continue; end; for j:=i-1 downto 1 do if x[j]<=x[i] then inc(count); increase(count); end; for i:=1 to n do sum[i]:=getsum(i); writeln(sum[1]); for i:=2 to n do writeln(sum[i]-sum[i-1]); end. |
|
|