possible. From the get go, Mr. Chanek has a grid an of size n×m Each phone (x,y) contains a number ax,y demonstrating the course of how the ball will move. ax,y=1 — the ball will move aside (the accompanying cell is (x,y+1)); ax,y=2 — the ball will move to the base (the accompanying cell is (x+1,y)); ax,y=3 — the ball will move aside (the accompanying cell is (x,y−1)). Each time a ball leaves a cell (x,
Please do it in c++ as soon as possible.
From the get go, Mr. Chanek has a grid an of size n×m
Each phone (x,y) contains a number ax,y demonstrating the course of how the ball will move.
ax,y=1 — the ball will move aside (the accompanying cell is (x,y+1));
ax,y=2 — the ball will move to the base (the accompanying cell is (x+1,y));
ax,y=3 — the ball will move aside (the accompanying cell is (x,y−1)).
Each time a ball leaves a cell (x,y), the number ax,y will change to 2. Mr. Chanek will drop k balls progressively, each start from the primary line, and on the c1,c2,… ,ck-th (1≤ci≤m) segments.
Choose in what segment each ball will end up in (position of the ball in the wake of leaving the grid).
Input
The chief line contains three whole numbers n, m, and k (1≤n,m≤1000, 1≤k≤105) — the size of the cross section and the amount of balls dropped by Mr. Chanek.
The I-th of the accompanying n lines contains m numbers
The accompanying line contains k whole numbers c1,c2,… ,ck (1≤ci≤m) — the balls' part positions dropped by Mr. Chanek progressively.
Yield
Yield k numbers — the I-th number showing the portion where the I-th ball will end.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images