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 nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Q1.nq. Given a 2d grid map of '1's (land) and '0's (water),count the number of islands.An island is surrounded by water and is formed byconnecting adjacent lands horizontally or vertically.You may assume all four edges of the grid are all surrounded by water. Example 1: 11110110101100000000Answer: 1 Example 2: 11000110000010000011Answer: 3""" def num_islands(grid): count = 0 for i in range(len(grid)): for j, col in enumerate(grid[i]): if col == 1: dfs(grid, i, j) count += 1 Please code it. .arrow_forwardPlease Answer in C++ language only Today the chef decided to cook some tasty dishes from the ingredients in his kitchen. There is an NN of components, represented by the strings S1,S2, .... SN. The chef took all the ingredients, put them in a cauldron and mixed them. In the cauldron, the letters of the strings representing the ingredients are completely shuffled, so that each letter appears in the cauldron as many times as it has appeared in all the strings combined; now the cook can take out one letter from the cauldron at will (if that letter appears in the cauldron more than once, it can be taken out that many times) and use it in a dish. Complete Food is a "chef" chain. Help the chef find the maximum number of complete meals he can make! Input 1 5 codechef chefcode fehcedoc cceeohfd codechef Output 5arrow_forwardUse C++ language Can you please give me a code that runs properly this time Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example, for the following board,X X X XX O O XX X O XX O X XAfter capturing all regions, the board becomesX X X XX X X XX X X XX O X XThe algorithm should take an input file, named “input.txt”, and output the resulting board in the console.Sample input.txt6X X X X X OX O X O O XX X O O O XX X X O X XX O X X O OX X X X X XThe first line is a number indicating the size of the board; in the above example, 6 means the board is .Output for in console:X X X X X OX X X X X XX X X X X XX X X X X XX X X X O OX X X X X Xarrow_forward
- Write a triangle (x0, y0, x1, y1, x2, y2) function to draw the triangle with vertices (x0, y0), (x1, y1), and (x2, y2). Use your function to draw some triangles. www..arrow_forwardA grid needs a system for numbering the tiles in order to allow random-access lookup.For instance, the rows and columns of a square grid provide a natural numbering for the tiles. Create plans for hexagonal and triangular grids. Create a rule for identifying the neighbourhood (i.e., nearby tiles) of a certain tile in the grid using the numbering scheme. For instance, the neighbourhood of tile I j in a four-connected square grid with indices of I for rows and j for columns may be described as neighbourhood(i, j) = I 1, j, I j 1.arrow_forwardIN HASKELL PROGRAMMING LANGUAGE PLEASE In case you do not know it: the game is played on a 3x3 grid that is initially empty. Two players are playing, by alternatingly making moves. A move by a player places their token (an X for player 1, an O for player 2) into a cell that was empty. We are using algebraic notations for indexing the positions in the board, with A,B,C indexing the columns and 1,2,3 the rows. Specifically, these coordinates would be used in the implementation for moves made by a human player. If the X X O Figure 1: Sample board position same token appears 3 times in any of the three columns, three rows or two main diagonals the game is over and that player wins. If the grid is filled without that happening the game is a draw. For the depicted board, we have Xs in positions C3 and A2, and an O in position B1. It would be O’s turn to make a move; a legal move would be C2, but it is not a good move, because X can force a win by responding A1. O cannot force a win, but…arrow_forward
- Javaarrow_forwardWrite a program in C that, given two points on a two-dimensional graph, outputs a message (string) if the line that connects them is horizontal or vertical, or if the slope is positive or negative.What would you modify or adjust in your code if we move from a 2D cartesian system to a 3D dimensional cartesian system?You need to take into consideration if the system is 3D and therefore you need to ask the user to insert X, Y , and Z.arrow_forwardI need the code from start to end with no errors and the explanation for the code ObjectivesJava refresher (including file I/O)Use recursionDescriptionFor this project, you get to write a maze solver. A maze is a two dimensional array of chars. Walls are represented as '#'s and ' ' are empty squares. The maze entrance is always in the first row, second column (and will always be an empty square). There will be zero or more exits along the outside perimeter. To be considered an exit, it must be reachable from the entrance. The entrance is not an exit.Here are some example mazes:mazeA7 9# # ###### # # ## # # #### # ## ##### ## ########## RequirementsWrite a MazeSolver class in Java. This program needs to prompt the user for a maze filename and then explore the maze. Display how many exits were found and the positions (not indices) of the valid exits. Your program can display the valid exits found in any order. See the examples below for exact output requirements. Also, record…arrow_forward
- Need help on this. Must be in java. Make the code uniqie and no plagerism. for the following four problems, consider the task of representing ticket types for campus events. Each ticket has a unique number and price. There are three types of tickets: walk-in tickets, advance tickets, and student advance tickets. Figure 9.10 illustrates the types: • Walk-in tickets are purchased on the day of the event and cost $ 50. • Advance tickets purchased 10 or more days prior to the event cost $ 30 and advance tickets purchased less than 10 days prior to the event. event cost $ 40. Student Advance Tickets are sold at half the price of regular Advance Tickets - when purchased 10 or more days in advance, they cost $ 15, and when purchased less than 10 days in advance, they cost $ 20. Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all the common operations in this class and specify all the different operations in such a way that each…arrow_forwardWrite a Java Program to print a 2D matrix in the Spiral format. You can assume the 2D matrix is your own.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education