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

Why WA1?
Posted by Ignat Zakrevsky 12 Jan 2012 14:14
I always have WA1?
Give me some tests

My code is here:
======================================

#include <iostream>
#include <math.h>
using namespace std;

void Attack(int &, int &, int &, int &);
void Guard(int &, int &);
void Defense(int &);
void Patrol(int &, int &);

void OffensiveStrike(int &, int &);
void RetreatStrike(int &, int &);

void LEFT(int &);
void RIGHT(int &);
void FRONT(int &);
void BACKWARD(int &);
void FIRE(int &);
void STOP();

int X,P;
int M,MP,MA;

int main()
{
cin >> X >> P;

char model;
cin >> model;

cin >> M >> MP >> MA;

if ('A'==model)
{
int N,NP;
cin >> N >> NP;
Attack(N,NP,M,MP);
} else
if ('G'==model)
Guard(M,MA);
else
if ('D'==model)
Defense(M);
else
if ('P'==model)
{
int A;
cin >> A;
Patrol(M,A);
}

}

void Attack(int &N, int &NP, int &M, int &MP)
{
if (N*NP>M*MP*3) OffensiveStrike(M,MA);
else RetreatStrike(M,MA);
}

void Guard(int &M, int &MA)
{
if (0==M) STOP;
else
if (MA>=5) LEFT(X);
else if (MA<=-5) RIGHT(P);
else FIRE(P);
}

void Defense(int &M)
{
if (M*20>=P) RetreatStrike(M,MA);
else Guard(M,MA);
}

void Patrol(int &M, int &A)
{
if (M>0) Defense(M);
else if (abs(A)<=20 || 180-abs(A)<=20)
{
if (abs(A)<=20) FRONT(X);
else BACKWARD(X);
} else
if ((A>=90 && A<160) || (A>=-90 && A<-20)) RIGHT(X);
else LEFT(X);

}

void OffensiveStrike(int &M, int &MA)
{
if (abs(MA)>=10 || 0==M) FRONT(X);
else FIRE(P);
}

void RetreatStrike(int &M, int &MA)
{
if (abs(MA)>=5 || 0==M) BACKWARD(X);
else FIRE(P);
}

void LEFT(int &X)
{
if (X>100) cout << "LEFT 100";
else   cout << "LEFT " << X;
}

void RIGHT(int &X)
{
if (X>100) cout << "RIGHT 100";
else   cout << "RIGHT " << X;
}

void FRONT(int &X)
{
if (X>100) cout << "FRONT 100";
else   cout << "FRONT " << X;
}

void BACKWARD(int &X)
{
if (X>100) cout << "BACKWARD 100";
else   cout << "BACKWARD " << X;
}

void FIRE(int &P)
{
if (P>20) cout << "FIRE 20";
else  cout << "FIRE " << P;
}

void STOP()
{
cout << "STOP";
}