#include #include #include #include using namespace std; typedef struct{ int x, y; }Pos; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int W,H,Sx,Sy,Ex,Ey; cin >> W >> H >> Sx >> Sy >> Ex >> Ey; int tmp[H/2][W/2]; for(int i=0; i> tmp[i][j]; } } vector heights; string xd; for(int i=0; i positions; if(Sx > Ex){ int tmp_S = Sx; Sx = Ex; Ex = tmp_S; tmp_S = Sy; Sy = Ey; Ey = tmp_S; } bool flag; for(int x=Sx; x heights[y][x]){ flag = true; } if(m > 0){ if(flag && heights[y-1][x] <= heights[y][x-1]){ tmp.x = x-1; tmp.y = y; positions.push_back(tmp); }else if(heights[y-1][x] > heights[x][y]){ tmp.x = x; tmp.y = y-1; positions.push_back(tmp); } }else{ if(flag && heights[y+1][x] <= heights[y][x-1]){ tmp.x = x-1; tmp.y = y; positions.push_back(tmp); }else if(heights[y+1][x] > heights[x][y]){ tmp.x = x; tmp.y = y+1; positions.push_back(tmp); } } } tmp.x = x; tmp.y = y; positions.push_back(tmp); if( D < 0 ){ y = y-1; D = D - 2*dx; } D = D + 2*dy; } double path_len = sqrt((double(Ex) - Sx)*(double(Ex) - Sx) + (double(Ey) - Sy)*(double(Ey) - Sy)); int cur_level = heights[positions[0].y][positions[0].x]; int pos_size = positions.size(); for(int i=1; i