Cod sursa(job #197974)

Utilizator andrici_cezarAndrici Cezar andrici_cezar Data 7 iulie 2008 14:55:09
Problema Gropi Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.48 kb
var f,g:text;
    c,x,y,s,l,n,k,a,b,q,aux,i,j:longint;
begin
assign(f,'gropi.in');reset(f);
assign(g,'gropi.out');rewrite(g);
readln(f,n,k);
for q:=1 to k do
    readln(f,b,a);
readln(f,l);
for q:=1 to l do
begin
readln(f,x,y,i,j);
if y>j then begin
            aux:=j;
            j:=y;
            y:=aux;
            aux:=x;
            x:=i;
            i:=aux;
            end;
c:=0;
if x=i then c:=1;
s:=(j-y+1)+1+(i-x)+1+c;
writeln(g,s);
end;
close(g);
end.