Go to diff to previous submission
#include <stdio.h> #include <math.h> int R,C, Lr, Lc, Gr, Gc; int get_dist(int a, int b, int x, int y) { } int main() { { int d = get_dist(Gr, Gc, Lr, Lc); int result = 0; if (d == 0) { } else if (R == 1 || C == 1) { } else if (R == 2 || C == 2) { int t = (x > y) ? x : y; if (Gr == Lr || Gc == Gc) { if ((t+2) % 4 == 0) { } else { if (t % 4 == 0) { } } else if (R == 3 && C == 3) { else { switch(d) { case 1: break; case 3: break; case 4: break; case 5: break; } } } else if (x != 0 && x*2 < y) { result = y/2; result += (y%2 > 0) ? 1 : 0; } else if (y != 0 && y*2 < x) { result = x/2; result += (x%2 > 0) ? 1 : 0; } else { if (x < 4 && y < 4) switch(d) { case 1: break; case 2: break; case 3: break; case 4: break; } else { result += (d % 3) > 0 ? 1 : 0; result += d/3; } } } return 0; }
--- c4.s1003.cteam074.grasshop.c.0.grasshop.c +++ c4.s1052.cteam074.grasshop.c.0.grasshop.c @@ -24,5 +24,4 @@ } else if (R == 2 || C == 2) { int t = (x > y) ? x : y; - printf("test %d\n", t); if (Gr == Lr || Gc == Gc) { if ((t+2) % 4 == 0) { @@ -35,6 +34,5 @@ } } else if (R == 3 && C == 3) { - if (d == 2) printf("impossible\n"); - else if (Lr == 2 && Lc == 2) printf("impossible\n"); + if (Lr == 2 && Lc == 2) printf("impossible\n"); else { switch(d) { @@ -53,13 +51,14 @@ } } - } else if (x*2 < y) { + } else if (x != 0 && x*2 < y) { result = y/2; result += (y%2 > 0) ? 1 : 0; printf("%d\n", result); - } else if (y*2 < x) { + } else if (y != 0 && y*2 < x) { result = x/2; result += (x%2 > 0) ? 1 : 0; printf("%d\n", result); } else { + if (x < 4 && y < 4) switch(d) { case 1: @@ -75,9 +74,5 @@ printf("3\n"); break; - case 5: - printf("3\n"); - break; - } - if (d > 5) { + } else { result += (d % 3) > 0 ? 1 : 0; result += d/3;