/* [NKP'05] Skiliften door: Jan Kuipers */ using namespace std; #include #include #include #include struct pos { int y,x,h; pos(int _y, int _x, int _h) { y=_y; x=_x; h=_h; } }; bool operator < (pos a, pos b) { return a.h>b.h; } int Y,X; vector > h,u; void fill (int y, int x) { if (u[y][x]) return; u[y][x]=1; if (y>0 && h[y-1][x]<=h[y][x]) fill(y-1,x); if (x>0 && h[y][x-1]<=h[y][x]) fill(y,x-1); if (y >(Y, vector(X,0)); vector p; for (int y=0; y> runs; for (int run=0; run> Y >> X; h = vector >(Y, vector(X)); bool flat=true; for (int y=0; y> h[y][x]; if (h[y][x]!=h[0][0]) flat=false; } if (flat) { cout << "0" << endl; continue; } int a = count(); for (int y=0; y