ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1028. Stars

Why Compilation Error????
Posted by wangyin 24 Jan 2006 17:47
type
  treetype=record
           a,b,lc,rc,cover:longint;
           end;
var
  tree:array[1..64001] of treetype;
  ans:array[0..32000] of longint;
  bx,by:array[1..15000] of longint;
  n,tot,i:longint;
function pt(p,r,x,y:longint):longint;
var
  i,j,temp:longint;
begin
  i:=p-1;j:=r+1;
  while true do
  begin
    repeat inc(i);until (bx[i]>x) or ((bx[i]=x) and (by[i]>=y));
    repeat dec(j);until (bx[j]<x) or ((bx[j]=x) and (by[j]<=y));
    if i<j then
    begin
      temp:=bx[i];bx[i]:=bx[j];bx[j]:=temp;
      temp:=by[i];by[i]:=by[j];by[j]:=temp;
    end
    else exit(j);
  end;
end;
procedure qs(p,r:longint);
var
  q:longint;
begin
  if p<r then
  begin
    q:=pt(p,r,bx[p],by[p]);
    qs(p,q);qs(q+1,r);
  end;
end;
procedure make(a,b:longint);
var
  now:longint;
begin
  inc(tot);now:=tot;
  tree[now].a:=a;
  tree[now].b:=b;
  if a+1<b then
  begin
    tree[now].lc:=tot+1;
    make(a,(a+b) div 2);
    tree[now].rc:=tot+1;
    make((a+b) div 2,b);
  end;
end;
procedure insert(num,c,d:longint);
begin
  if (c<=tree[num].a) and (tree[num].b<=d) then
  inc(tree[num].cover)
  else
  begin
    if c<(tree[num].a+tree[num].b) div 2 then
    insert(tree[num].lc,c,d);
    if d>(tree[num].a+tree[num].b) div 2 then
    insert(tree[num].rc,c,d);
  end;
end;
function count(num,a,b:longint):longint;
begin
  count:=0;
  if tree[num].cover>0 then
  exit(tree[num].cover*(tree[num].b-tree[num].a))
  else
  if tree[num].a+1<tree[num].b then
  begin
    if a<(tree[num].a+tree[num].b) div 2 then
    count:=count+count(tree[num].lc,a,b);
    if b>(tree[num].a+tree[num].b) div 2 then
    count:=count+count(tree[num].rc,a,b);
  end;
end;
begin
  readln(n);
  for i:=1 to n do
  readln(bx[i],by[i]);
  qs(1,n);
  tot:=0;
  fillchar(ans,sizeof(ans),0);
  fillchar(tree,sizeof(tree),0);
  make(0,32001);
  for i:=1 to n do
  begin
    inc(ans[count(1,0,by[i]+1)]);
    insert(1,by[i],by[i]+1);
  end;
  for i:=0 to n-1 do writeln(ans[i]);
end.
Function 'exit' is not declared (-)
Posted by Dmitry 'Diman_YES' Kovalioff 24 Jan 2006 19:06
Re: Function 'exit' is not declared (-)
Posted by 1898098 23 Oct 2007 21:30
the compiler is not suppose exit();

you should write:

  function:=111;
  exit;

not exit(111);

Edited by author 23.10.2007 21:32

Edited by author 23.10.2007 21:32