PLEASE USE C PROGRAMMING TO CODE THIS PROBLEM. EXPLAIN the logic with us of a diagram if possible, or clear enough that i can write this code if I was to ever come across a problem like it again Description Given a board with N rows and M columns, the rows are numbered from 1 to N from top to bottom, and the columns are numbered from 1 to M from left to right. Each element has one diagonal wall which either runs from top-left corner to bottom-right corner, or runs from top-right corner to bottom-left corner. Now given Q queries, you have to output which column the ball will fall out at the bottom row if you put it on top of the board at specific column. (The ball will naturally fall down due to gravity.) The following figure is a sample. If you drop the ball at column 2, the ball will fall out at the left side. If you drop the ball at column 5, the ball will be stuck in the board. If you drop the ball at column 3, the ball will eventually fall out at column 2. Input First line contains two integers which represent n, m respectively. (1 <= n, m <= 500). The following N lines which have M characters in each line represent the board. '/' means the wall runs from top-right corner to bottom-left corner, and '\' means the wall runs from top-left corner to bottom-right corner. Next line contains an integer Q which denotes the number of querys. (1 <= Q <= 100). Then, the following Q line, each line has one integer which represents the starting column to drop the ball. Output For each queries: If the ball fall out at the right side, you should output "Right!". If the ball fall out at the left side, you should output "Left!". If the ball stuck at the board, you should output "Stuck QQ". Otherwise, you should output "Position: x". x represents which column the ball fall out at the bottom row. Remember to output '\n' at the end of each line. Sample Input Download 5 6 \\//\\ /\\\\\ //\\\\ \\\\\/ \\//// 6 1 2 3 4 5 6 Sample Output Download Position: 4 Stuck QQ Stuck QQ Stuck QQ Right! Right!
PLEASE USE C PROGRAMMING TO CODE THIS PROBLEM. EXPLAIN the logic with us of a diagram if possible, or clear enough that i can write this code if I was to ever come across a problem like it again
Description
Given a board with N rows and M columns, the rows are numbered from 1 to N from top to bottom, and the columns are numbered from 1 to M from left to right. Each element has one diagonal wall which either runs from top-left corner to bottom-right corner, or runs from top-right corner to bottom-left corner. Now given Q queries, you have to output which column the ball will fall out at the bottom row if you put it on top of the board at specific column. (The ball will naturally fall down due to gravity.)
The following figure is a sample. If you drop the ball at column 2, the ball will fall out at the left side. If you drop the ball at column 5, the ball will be stuck in the board. If you drop the ball at column 3, the ball will eventually fall out at column 2.
Input
First line contains two integers which represent n, m respectively. (1 <= n, m <= 500).
The following N lines which have M characters in each line represent the board. '/' means the wall runs from top-right corner to bottom-left corner, and '\' means the wall runs from top-left corner to bottom-right corner.
Next line contains an integer Q which denotes the number of querys. (1 <= Q <= 100).
Then, the following Q line, each line has one integer which represents the starting column to drop the ball.
Output
For each queries:
If the ball fall out at the right side, you should output "Right!".
If the ball fall out at the left side, you should output "Left!".
If the ball stuck at the board, you should output "Stuck QQ".
Otherwise, you should output "Position: x". x represents which column the ball fall out at the bottom row.
Remember to output '\n' at the end of each line.
Sample Input Download
\\//\\
/\\\\\
//\\\\
\\\\\/
\\////
6
1
2
3
4
5
6
Sample Output Download
Position: 4
Stuck QQ
Stuck QQ
Stuck QQ
Right!
Right!
Step by step
Solved in 3 steps with 1 images