Go to diff to previous submission
#include <stdio.h> int width,height,fx,fy; int check[101][101]; void rek(int sx, int sy, int step) { static int stepX[] = {1, 2, 2, 1, -1, -2, -2, -1}; static int stepY[] = {2, 1, -1, -2, -2, -1, 1, 2}; int i, nextX, nextY; check[sx][sy] = step; for(i=0; i<8; i++){ nextX = sx + stepX[i]; nextY = sy + stepY[i]; if(nextX <= 0 || nextX > width) continue; if(nextY <= 0 || nextY > height) continue; if(check[nextX][nextY] > step+1) rek(nextX, nextY, step+1); } return; } int main( int agrc, char * argv[] ) { int sx,sy,i,j; { for (i=0; i<101;i++) for (j=0; j<101;j++) check[i][j]=50; rek(sx, sy, 0); if(check[fx][fy] == 50) else } return 0; }
--- c4.s1205.cteam043.grasshop.c.0.grasshop.c +++ c4.s1230.cteam043.grasshop.c.0.grasshop.c @@ -14,6 +14,6 @@ nextX = sx + stepX[i]; nextY = sy + stepY[i]; - if(nextX < 0 || nextX >= width) continue; - if(nextY < 0 || nextY >= height) continue; + if(nextX <= 0 || nextX > width) continue; + if(nextY <= 0 || nextY > height) continue; if(check[nextX][nextY] > step+1) rek(nextX, nextY, step+1); @@ -32,7 +32,7 @@ for (i=0; i<101;i++) for (j=0; j<101;j++) - check[i][j]=200000000; + check[i][j]=50; rek(sx, sy, 0); - if(check[fx][fy] == 200000000) + if(check[fx][fy] == 50) printf("impossible\n"); else