# Timeout

I've written the code below for solving the problem 1112 of the UriOnlineJudge website and apparently, the logic used is perfect, but I'm getting a timeout error. I can not identify the error. This seems to be in the first scanf (), because when I run the program, I can type an infinite sequence of 0s and spaces so that the program only returns zero and closes when the Enter key is pressed, but I do not do not know what to do for that. consecutive zeros in the first entry already closed. I believe that it is necessary that, when reading these three data, even without pressing the Enter key, the program ends when there are three zeros.

``````#include

int main () {
int X, Y, P, Q;
int i, j, k, l;
char carac;
while (1) {
scanf ("% d% d% d", & X, & Y, & P);
if (X == 0 && Y == 0 && P == 0) {
returns 0;
}
int field[X][Y];
for (i = 0; i <X; i ++) {
for (j = 0, j <Y; j ++) {
field[i][j]= 0;
}
}
scanf ("% d", & Q);
int N = 0, Z, W, qtd;
for (i = 0; i <Q; i ++) {
qtd = 0;
scanf ("% c", & carac);
if (carac == A #)
scanf ("% d% d% d", & N, & X, & Y);
field[X][Y]+ = N;
}
if not {
scanf ("% d% d% d% d", & X, & Y, & Z, & W);
for (j = X; j<=Z;j++){
if(Y>W)
l = Y;
Y = W;
W = 1;
}
for (k = Y; k <= W; k ++) {
qtd + = field[j][k];
}
}
printf ("% d  n", qtd * P);
}
}
}
}
``````