#include <cstdio>
#include <cstring>
using namespace std;
bool white;
void placedPiece(int x, int y);
void placePiece(int &x, int &y);
void movedPiece(int fromX, int fromY, int toX, int toY);
void movePiece(int &fromX, int &fromY, int &toX, int &toY);
int main() {
white = false;
char s[10]; //stores the data read from stdin
int numPlaced = 0;
while (true) {
scanf("%s", s);
if (!strcmp(s, "Quit")) return 0; //Quit the game when we read "Quit"
if (!strcmp(s, "Start")) {
//The first turn, so we're white and go first
white = true;
} else if (numPlaced<49) {
int x = s[0]-'A';
int y = s[1]-'1';
placedPiece(x, y); //tell the opponent placed a piece
++numPlaced;
} else {
int fromX = s[0]-'A';
int fromY = s[1]-'1';
int toX = s[2]-'A';
int toY = s[3]-'1';
movedPiece(fromX, fromY, toX, toY); //tell the opponent moved a piece
}
if (numPlaced<49) {
++numPlaced;
int x, y;
placePiece(x, y); //ask to place a piece
s[0] = x+'A';
s[1] = y+'1';
s[2] = 0;
printf("%s\n", s); //output the move
fflush(stdout);
}
if (numPlaced>=49) {
int fromX, fromY, toX, toY;
movePiece(fromX, fromY, toX, toY); //ask to move a piece
s[0] = fromX+'A';
s[1] = fromY+'1';
s[2] = toX+'A';
s[3] = toY+'1';
s[4] = 0;
printf("%s\n", s); //output the move
fflush(stdout);
}
}
}
//x is the diagonal column (columns are diagonal, so the A columns is called 0,
// and has only 3 rows (see the image on codecup.org)
//y is the row, and starts at 0.
void placedPiece(int x, int y) {
//store the opponents placed piece
}
void placePiece(int& x, int& y) {
//calculate where to place a piece and store it in the arguments
}
void movedPiece(int fromX, int fromY, int toX, int toY) {
//store the the opponents move
}
void movePiece(int& fromX, int& fromY, int& toX, int& toY) {
//calculate a move and store it in the arguments
}
syntax highlighted by Code2HTML, v. 0.9.1