P2974 [USACO10HOL] Cow War G

Description

Farmer John has long had a dispute with neighbor Farmer Tom over a group of V (1

Input Format

\* Line 1: Two space separated integers: V and E \* Line 2: A string of V characters (no spaces); character #i indicates whether pasture #i is empty ('E') or has a cow owned by Farmer John ('J') or Farmer Tom ('T') \* Lines 3..E+2: Line i+2 contains two space separated integers: P1\_i and P2\_i

Output Format

\* Line 1: A single integer, the maximum number of enemy cows Farmer John can have tipped \* Lines 2.....: One of Farmer John's instructions to his cows (to be executed in the order given): MOVE A B or ATTACK A B where A is the vertex the cow occupies before taking the action and B is the vertex it is moving to or attacking, respectively. Note that when instructing a cow that has already moved to attack, the instruction specifies the location the cow is currently standing, not where it was originally.

Explanation/Hint

The other valid outputs are: 2 MOVE 3 2 ATTACK 5 4 ATTACK 2 1 and 2 ATTACK 5 4 MOVE 3 2 ATTACK 2 1 which are just reorderings of the output shown. This might not be true on other testdata.