Every cell (x,y) contains an integer ax,y signifying the course of how the ball will move. ax,y=1 — the ball will move to one side (the following cell is (x,y+1)); ax,y=2 — the ball will move to the base (the following cell is (x+1,y)); ax,y=3 — the ball will move to one side (the following cell is (x,y−1)).  Each time a ball leaves a cell (x,y), the integer ax,y will change to 2. Mr. Chanek will drop k balls successively, each beginning from the

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

Submit in python or c++. Error code will downvoted.

 

Every cell (x,y) contains an integer ax,y signifying the course of how the ball will move. ax,y=1 — the ball will move to one side (the following cell is (x,y+1)); ax,y=2 — the ball will move to the base (the following cell is (x+1,y)); ax,y=3 — the ball will move to one side (the following cell is (x,y−1)). 

Each time a ball leaves a cell (x,y), the integer ax,y will change to 2. Mr. Chanek will drop k balls successively, each beginning from the primary line, and on the c1,c2,… ,ck-th (1≤ci≤m) sections. Decide in which segment each ball will wind up in (position of the ball in the wake of leaving the network). 

Input :The principal line contains three integers n, m, and k (1≤n,m≤1000, 1≤k≤105) — the size of the framework and the number of balls dropped by Mr. Chanek. The I-th of the following n lines contains m integers ai,1,ai,2,… ,ai,m (1≤ai,j≤3). It will fulfill ai,1≠3 and ai,m≠1. The following line contains k integers c1,c2,… ,ck (1≤ci≤m) — the balls' section positions dropped by Mr. Chanek successively. 

Output :Output k integers — the I-th integer signifying the segment where the I-th ball will end.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
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