Question: Write a program to estimate years for all civilizations to be connected through adjacent areas (squares). Think of the world as a two-dimensional space where

 Write a program to estimate years for all civilizations to be

Write a program to estimate years for all civilizations to be connected through adjacent areas (squares). Think of the world as a two-dimensional space where there are NxN squares. For example, if N-4, it is like below Input: In the first line, there are two numbers, N and K as world size and number of civilizations. In the next K lines, there are two numbers x and y, one orn each line, indicating the position of the square corresponding to the birthplace of the civilization (1 Sx, y N) Output: years to connect all civilizations. The square at the bottom left is in the (1, 1) position. The square at the top right is in the (N, N) position. Two squares (a, b) and (a', b') are adjacent to each nput other when both of the following two conditions are satisfied. Example 1 10 3 This is an example 1 3 1 8 5,5) Condition 1: la-a'l -1 and b-b' Condition 2: Ib-b'l 1 and a-a Output The first birthplace of civilization is all in different K 2 squares. The space of each square is civilized or undeveloped. The first birthplace of civilization is a civilization area. Every year, civilization spreads civilization to its neighbor (adjacent squares). If the 54 square (a, b) is a civilized area, civilization will spread 11 to the square next to this square, unless the boundary of the world is exceeded in the next year 5 Example 2 Input 2 1 5 2 Output Write a program to estimate years for all civilizations to be connected through adjacent areas (squares). Think of the world as a two-dimensional space where there are NxN squares. For example, if N-4, it is like below Input: In the first line, there are two numbers, N and K as world size and number of civilizations. In the next K lines, there are two numbers x and y, one orn each line, indicating the position of the square corresponding to the birthplace of the civilization (1 Sx, y N) Output: years to connect all civilizations. The square at the bottom left is in the (1, 1) position. The square at the top right is in the (N, N) position. Two squares (a, b) and (a', b') are adjacent to each nput other when both of the following two conditions are satisfied. Example 1 10 3 This is an example 1 3 1 8 5,5) Condition 1: la-a'l -1 and b-b' Condition 2: Ib-b'l 1 and a-a Output The first birthplace of civilization is all in different K 2 squares. The space of each square is civilized or undeveloped. The first birthplace of civilization is a civilization area. Every year, civilization spreads civilization to its neighbor (adjacent squares). If the 54 square (a, b) is a civilized area, civilization will spread 11 to the square next to this square, unless the boundary of the world is exceeded in the next year 5 Example 2 Input 2 1 5 2 Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!