Go to diff to previous submission
#include<stdio.h> int main(){ int l, ant; scanf("%d %d", &l, &ant); char pole[l]; for(int i = 0;i < l;i++){ pole[i] = '0'; } int poz; char index; for(int x = 0; x < ant ;x++){ scanf("%d %c", &poz, &index); pole[poz]=index; } int left = 0; int right = 0; int v = 0; int pozright = 0; int y = l; while ((left == 0)){ if (pole[y] == 'L'){ left = y + 1; break; } if (y == 0) {break;} y--; } while(right == 0) { if (pole[v] == 'R'){ right = v; pozright = right; right = l - right + 1; } if(v == l) {break;} v++; } if (right > left){ printf("The last ant will fall down in %d seconds - started at %d.\n", right - 1, pozright); }else if (left > right){ printf("The last ant will fall down in %d seconds - started at %d.\n", left - 1, left - 1); }else{ int a = 0, b = 0; for (int i = l / 2; i < l; i++){ if (pole[i] != '0'){ b = i; break; } } for(int i = (l / 2) - 1; i > 0; i-- ){ if (pole[i] != '0'){ a = i; break; } } printf("The last ant will fall down in %d seconds - started at %d and %d.\n", right - 1, a, b); } return 0; }
--- c4.s1065.cteam104.ants.cpp.0.ants.cpp +++ c4.s1097.cteam104.ants.cpp.0.ants.cpp @@ -64,13 +64,13 @@ if (right > left){ - printf("The last ant will fall down in %d seconds - started at %d\n", right - 1, pozright); + printf("The last ant will fall down in %d seconds - started at %d.\n", right - 1, pozright); }else if (left > right){ - printf("The last ant will fall down in %d seconds - started at %d\n", left - 1, left - 1); + printf("The last ant will fall down in %d seconds - started at %d.\n", left - 1, left - 1); }else{ - int a, b; + int a = 0, b = 0; for (int i = l / 2; i < l; i++){ @@ -97,5 +97,5 @@ } - printf("The last ant will fall down in %d seconds - started at %d and %d\n", right - 1, a, b); + printf("The last ant will fall down in %d seconds - started at %d and %d.\n", right - 1, a, b); }