ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1299. Psylonians

Test #1 WA. I don't know what's the problem
Posted by Artemon 28 Sep 2018 20:10
void fallBack(int angle, int M, int curEnergy, int curAmmo);
void advance(int angle, int M, int curEnergy, int curAmmo);
int findX(int curEnergy);

int main()
{
int curEnergy, curAmmo;
char behaviour;
int M, MP, angle;
int N, NP, offset;
scanf_s("%i %i", &curEnergy, &curAmmo);
scanf_s(" %c", &behaviour);
scanf_s("%i %i %i", &M, &MP, &angle);
if (behaviour == 'A') {
scanf_s("%i %i", &N, &NP);
}
else if (behaviour == 'P') {
scanf_s("%i", &offset);
offset *= -1;

}
while (1) {
switch (behaviour) {
case 'A':
if ((N*NP) > (M*MP * 3)) {
advance(angle, M, curEnergy, curAmmo);
return 0;
}
else {
fallBack(angle, M, curEnergy, curAmmo);
return 0;
}
case 'D':
if ((M * 20) >= curAmmo) {
fallBack(angle, M, curEnergy, curAmmo);
return 0;
}
else {
behaviour = 'G';
break;
}
case 'G':
if (M == 0) {
printf("STOP");
}
if (abs(angle) < 5) {
int P = (int)fmin(20, curAmmo);
printf("FIRE %i", P);
return 0;
}
else if (angle >= 5) {
printf("LEFT %i", findX(curEnergy));
return 0;
}
else if (angle <= -5) {

printf("RIGHT %i", findX(curEnergy));
return 0;
}
case 'P':
if (M != 0) {
behaviour = 'D';
break;
}
else {
if (offset >= -180 && offset <= -160) {
printf("BACKWARD %i", findX(curEnergy));
return 0;
}
else if (offset > -160 && offset < -90) {
printf("RIGHT %i", findX(curEnergy));
return 0;
}
else if (offset >= -90 && offset < -20) {
printf("LEFT %i", findX(curEnergy));
return 0;
}
else if (offset >= -20 && offset <= 20) {
printf("FRONT %i", findX(curEnergy));
return 0;
}
else if (offset > 20 && offset <= 90) {
printf("RIGHT %i", findX(curEnergy));
return 0;
}
else if (offset > 90 && offset < 160) {
printf("LEFT %i", findX(curEnergy));
return 0;
}
else if (offset >= 160 && offset <= 180) {
printf("BACKWARD %i", findX(curEnergy));
return 0;
}
}
}
}

return 0;
}

void fallBack(int angle, int M, int curEnergy, int curAmmo)
{
if (abs(angle) >= 5 || M == 0) {
printf("BACKWARD %i", findX(curEnergy));
}
else {
int P = (int)fmin(20, curAmmo);
printf("FIRE %i", P);
}
}
void advance(int angle, int M, int curEnergy, int curAmmo)
{
if (abs(angle) >= 10 || M == 0) {
printf("FRONT %i", findX(curEnergy));
}
else {
int P = (int)fmin(20, curAmmo);
printf("FIRE %i", P);
}
}
int findX(int curEnergy)
{
int X;
if (curEnergy > 100) {
X = 100;
}
else {
X = curEnergy;
}
return X;
}