class Robot {
private:
int step;
int width;
int height;
public:
Robot(int width, int height) {
this->width = width;
this->height = height;
step = 0;
}
void move(int num) {
step = (step + num - 1) % ((width + height - 2) * 2) + 1;
}
vector<int> getPos() {
auto [x, y, _] = getPosAndDir();
return {x, y};
}
tuple<int, int, string> getPosAndDir() {
if (step < width) {
return make_tuple(step, 0, "East");
} else if (step < width + height - 1) {
return make_tuple(width - 1, step - width + 1, "North");
} else if (step < width * 2 + height - 2) {
return make_tuple(width * 2 + height - 3 - step, height - 1, "West");
} else {
return make_tuple(0, (width + height - 2) * 2 - step, "South");
}
}
string getDir() {
auto [x, y, dir] = getPosAndDir();
return dir;
}
};
/**
* Your Robot object will be instantiated and called as such:
* Robot* obj = new Robot(width, height);
* obj->move(num);
* vector<int> param_2 = obj->getPos();
* string param_3 = obj->getDir();
*/