// fun.cpp // Fun House, MCPC 2014, Problem B // C++ solution by James Feher #include #include #include using namespace std; ifstream fin( "fun.in" ); bool DEBUG = false; // Make sure to set to false on submission int W, L; char room[21][21]; int findEntrance(int &inX, int&inY) { // set the location of the input to the room // return the direction of the beam // 0 - right, 1 - left, 2 - up, 3 - down int i, direction; bool found = false; // check the top && bottom rows for (i=0; i> W; // Get the width of the room while (W > 0) { fin >> L; DEBUG && cout << "Got Data -- W: " << W << "\tL: " << L << endl; // get each row in the room array of chars for (i=0; i> room[i]; if (DEBUG) { cout << "INPUT ROOM: \n"; for (i=0; i2, left goes down 1->3 // up goes right 2->0, down goes left 3->1 direction = (direction + 2) % 4; } if (room[Y][X] == '\\') { // Escape the \\ // right goes down 0->3, left goes up 1->2 // down goes right 3->0, up goes left 2->1 if (direction == 0) direction = 3; else if (direction == 3) direction = 0; else if (direction == 1) direction = 2; else if (direction == 2) direction = 1; } } } room[Y][X] = '&'; cout << "HOUSE " << houseNum << endl; for (i=0; i> W; houseNum++; } return 0; }