Go to diff to previous submission
#include <stdio.h> #define LEFT 'L' #define RIGHT 'R' #define NONE '\0' int falltime(int position, char direction, int length) { if (direction == 'R') { return length - position; } return position; } char directions[100000]; int main(void) { int length, count, position, time, max_time, i, l, r, last_left_going_left, last_left_going_right, last_right_going_left, last_right_going_right, max, max2, pos, pos2; int posibilities[4], posibilities_directions[4]; char direction; for (i = 0; i <= length; ++i) { directions[i] = NONE; } max_time = -1; i = count; while (i--) { } directions[position] = direction; } last_left_going_right = length + 1; last_right_going_left = -1; last_left_going_left = -1; last_right_going_right = -1; for (i = count, l = 0, r = length; l <= length && r >= 0; ++l, --r) { if (directions[l] == RIGHT) { last_left_going_right = l; } else if (directions[l] == LEFT) { if (last_left_going_right < l) { directions[last_left_going_right] = NONE; --i; last_left_going_left = last_left_going_right; directions[l] = RIGHT; last_left_going_right = l; } else { directions[l] = NONE; --i; last_left_going_left = l; } } if (directions[r] == LEFT) { last_right_going_left = r; } else if (directions[r] == RIGHT) { if (last_right_going_left > r) { directions[last_right_going_left] = NONE; --i; last_right_going_right = last_right_going_left; directions[r] = LEFT; last_right_going_left = r; } else { directions[r] = NONE; --i; last_right_going_right = r; } } } i = 0; if (last_left_going_right != length + 1) { posibilities[i] = last_left_going_right; posibilities_directions[i] = RIGHT; ++i; } if (last_left_going_left >= 0) { posibilities[i] = last_left_going_left; posibilities_directions[i] = LEFT; ++i; } if (last_right_going_left >= 0) { posibilities[i] = last_right_going_left; posibilities_directions[i] = LEFT; ++i; } if (last_right_going_right >= 0) { posibilities[i] = last_right_going_right; posibilities_directions[i] = RIGHT; ++i; } max = max2 = -1; pos = pos2 = -1; i -= 1; while (i >= 0) { //printf("[%d] = %d %c\n", i, posibilities[i], posibilities_directions[i]); //printf("max is %d\n", posibilities[i]); max2 = max; pos2 = pos; pos = posibilities[i]; } --i; } if (max == max2 && pos != pos2) { if (pos < pos2) { } else { } } else { } } return 0; }
--- c4.s1224.cteam044.ants.c.0.ants.c +++ c4.s1313.cteam044.ants.c.0.ants.c @@ -64,7 +64,5 @@ } } - } - for (i = count, l = 0, r = length; l <= length && r >= 0; ++l, --r) { if (directions[r] == LEFT) { last_right_going_left = r; @@ -75,5 +73,5 @@ --i; last_right_going_right = last_right_going_left; - directions[l] = LEFT; + directions[r] = LEFT; last_right_going_left = r;