All pastes #1971477 Raw Edit

Unnamed

public text v1 · immutable
#1971477 ·published 2010-10-24 03:54 UTC
rendered paste body
var i,j,k,m,n,minp:longint;
min:real;
   dist:array[0..1001,0..1001] of real;
    boo:boolean;
    a,b:array[0..1001] of longint;
    c:array[0..1001,0..1001] of longint;
    taken,seaten:array[0..1001] of boolean;
    pos,seat:array[0..1001,1..2] of longint;
    
function dis(x1,y1,x2,y2:longint):real;
begin
  dis:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;
begin
  readln(n,m);
  fillchar(taken,sizeof(taken),false);
  for i:=1 to n do begin
    readln(pos[i,1],pos[i,2]);
  end;
  for i:=1 to m do begin
    readln(seat[i,1],seat[i,2]);
  end;
  for i:=1 to n do begin
    for j:=1 to m do begin
      dist[i,j]:=dis(pos[i,1],pos[i,2],seat[j,1],seat[j,2]);
    end;
  end;
  for i:=1 to n do begin
  min:=maxlongint;
    for j:=1 to m do begin
      if dist[i,j]<min then begin
        min:=dist[i,j];
        minp:=j;
      end;
    end;
    a[i]:=minp;
    inc(c[minp,0]);
    c[minp,c[minp,0]]:=i;
  end;
  fillchar(seaten,sizeof(seaten),false);
  for i:=1 to n do begin
    boo:=true;
    if taken[a[i]]=false then begin
      boo:=false;
      for j:=1 to c[a[i],0] do begin
        if seaten[c[a[i],j]]=false then
        if  dist[c[a[i],j],a[i]]<dist[i,a[i]] then boo:=true;
        if boo=true then break;
      end;
    end;
    if boo then writeln(i);
    if not boo then begin
      taken[a[i]]:=true;
      seaten[i]:=true;
    end;
  end;
end.