/* [NWERC'07] Escape from enemy territory by: Jaap Eldering */ #include #include const int infty = 999999; const int dx[4] = { 1, 0,-1, 0 }; const int dy[4] = { 0, 1, 0,-1 }; #define maxn 10000 #define maxs 1000 int N, X, Y; int pos[maxn+2][2]; // 0 = init, 1 = rendezvouz, bases int sep[maxs+1][maxs+1]; int best[maxs+1][maxs+1][2]; // (x,y) -> (minsep, dist) int min(int a, int b) { if ( a=X || y1<0 || y1>=Y ) continue; if ( sep[x][y]+1=X || y1<0 || y1>=Y ) continue; if ( sep[x1][y1]>=trysep && dist[x][y]+1maxn ) return 1; if ( X<1 || X>maxs ) return 1; if ( Y<1 || Y>maxs ) return 1; for(i=0; iX || pos[i][1]<0 || pos[i][1]>Y ) return 1; } for(i=0; i