美文网首页
讲解:Data Structure、Python,c/c++、J

讲解:Data Structure、Python,c/c++、J

作者: zhetongmang | 来源:发表于2020-01-12 16:01 被阅读0次

Data Structure Assignment # 2BFS(Breadth-First Search)–Routing from the root node (the start node) to the nearest node first, and later to the far node–You should visit all nodes once–Use queue data structure which can retrieve the visited nodes in order. (FIFO)–You have to use BFS to solve this assignment.Solve a problem: Queue–Hyeonahs tomato farm has a large warehouse for storing tomatoes–The tomatoes are placed in a box (a grid-shaped box) as shown in the picture below and stored in a warehouse –Some of the tomatoes stored in the warehouse are ripe, but some are unripe.–After a day of storage, unripe tomatoes will ripe if its neighbors contain of ripe tomatoes.–The neighbors of one tomato are the tomatoes in the left, right, front, or back.–Assume there is no effect to tomatoes in the diagonal direction and assumes that the tomatoes do not ripen by themselves.–When storing the tomatoes at her warehouse, Hyeonah wants to know what is the minimum number of days that all of the tomatoes will ripe.–Given the size of the grid-shaped box that is used to store the tomatoes in the warehouse, and the 代做Data Structure作业、Python,c/c++课程作业代写、Java编程语言作业代写、代做BFS留学生作information of ripe tomatoes and unripe tomatoes, write a program to get the minimum number of days that all of the tomatoes will ripen a few days.–However, note that some boxes may not contain tomatoes–Set one of the tomatoes as the root node (start node) and then use BFS to solve the problem�Examples of Input–In the first line, enter the number of test cases.–The second line contains two integers, M and N, indicating the size of the grid-shaped box.–M is the horizontal size, and N is the vertical size of the grid-shaped box.–Conditionally, 2 ≤ M, N ≤ 1,000.–The third line contains information about the tomatoes stored in a box. The input will be a matrix with size M x N.–In the matrix, an integer 1 represents a ripe tomato, an integer 0 represents unripe tomatoes, and an integer -1 represents a space containing no tomato.–You should print the minimum days until the tomatoes are all ripeExamples of Ouput–If all the tomatoes have been ripen from the time they are stored, 0 should be the output.–If the all tomatoes are not ripe, they should be printed as -1.Examples of Input & Ouput转自:http://www.7daixie.com/2019050148153093.html

相关文章

网友评论

      本文标题:讲解:Data Structure、Python,c/c++、J

      本文链接:https://www.haomeiwen.com/subject/trtwactx.html