#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 0 && y > 0 && heights[y-1][x-1] > heights[y-1][x]){ // flag = true; // } if (x > 0 && y > 0) { if (m > 0) { if (x < W-1 && heights[y-1][x] >= heights[y][x] && heights[y][x+1] >= heights[y][x]) { if (heights[y-1][x] < heights[y][x + 1]) { tmp.x = x; tmp.y = y - 1; } else { tmp.x = x + 1; tmp.y = y; } positions.push_back(tmp); } } else { if (y < H-1 && x < W-1 && heights[y+1][x] >= heights[y][x] && heights[y][x+1] >= heights[y][x]) { if (heights[y+1][x] < heights[y][x + 1]) { tmp.x = x; tmp.y = y + 1; } else { tmp.x = x + 1; tmp.y = y; } 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 = sqrtl((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