Question
Binary SearchIntervals You have to manage indexes and list of a 2 dimensional array in this puzzle. You also discover the binary search algorithm and
Binary SearchIntervals
You have to manage indexes and list of a 2 dimensional array in this puzzle. You also discover the binary search algorithm and finally, it makes you know that batman is really good at cleaning windows.
External resources
Multidimensional arrayBinary search2D Binary Search explained by Gaurav Sen
STATEMENT
The goal of this puzzle is to guess the coordinate of a bomb (line and column of a 2 dimensional array). You will have to make a guess at each step of the puzzle and adjust it from given feedbacks. Of course, you have a limited number of guess.
#include
using namespace std;
/** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ 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();
// game loop while (1) { string bombDir; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL) cin >> bombDir; cin.ignore();
// Write an action using cout. DON'T FORGET THE "<< endl" // To debug: cerr << "Debug messages..." << endl;
// the location of the next window Batman should jump to. cout << "0 0" << endl; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started