#include using namespace std; typedef long long int ll; typedef double ld; struct Pt{ ld x,y,z; }; ld dist(Pt a, Pt b){ Pt c={b.x-a.x,b.y-a.y,b.z-a.z}; return sqrt(c.x*c.x+c.y*c.y+c.z*c.z); } vector> a; ll closest_height(ld x, ld y){ ll xx=(int)floor(x); ll yy=(int)floor(y); /* cerr<>W>>H>>Sx>>Sy>>Ex>>Ey; --Sx;--Sy;--Ex;--Ey; a=vector>(H/2,vector(W/2)); for(auto &v:a)for(ll &i:v)cin>>i; ld x=Sx; ld y=Sy; ld dx=Ex-Sx; ld dy=Ey-Sy; ld step=1e-7; Pt last; Pt cur={x,y,(ld)closest_height(x,y)}; ld res=0; for(ld ratio=0;ratio<1;ratio+=step){ last=cur; x=Sx+ratio*dx; y=Sy+ratio*dy; cur={x,y,(ld)closest_height(x,y)}; /* if(cur.z != last.z){ */ /* cerr<<"z: "<