#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int w; // width of the building.
int h; // height of the building.
cin >> w >> h; cin.ignore();
int n; // maximum number of turns before game over.
cin >> n; cin.ignore();
int x0;
int y0;
cin >> x0 >> y0; cin.ignore();
int w0 = 0 , h0 = 0;
// game loop
while (1) {
string bomb_dir; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
cin >> bomb_dir; cin.ignore();
if (bomb_dir.find("U") != string::npos){
h = y0;
y0 = ((y0+h0)/2) ;
}
if (bomb_dir.find("D") != string::npos){
h0 = y0;
y0 = floor((y0+h)/2);
}
if(bomb_dir.find("R") != string::npos){
w0 = x0;
x0 = floor((x0+w) /2);
}
if(bomb_dir.find("L") != string::npos){
w = x0;
x0 = floor((x0+w0)/2);
}
cout << to_string(x0) + " " + to_string(y0) << endl;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter