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!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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!

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education