PYTHON PROGRAMMING!! EXTRA CONSTRAINT: MAKE SURE THAT THE CODE ACCEPTS THE INPUT ON THE IMAGE AND OUTPUTS THE RESULT ON THE IMAGE AS WELL You find yourself in a top-secret mission to infiltrate and disable the nuclear missile silos of a terrorist organization threatening to destroy any country that refuses to surrender. Fortunately, an ally double agent was able to successfully hijack the launch system used by the terrorists. However, in order to not get found out, they could not disable the system outright but they were able to infect the system with an undetectable virus that stops all processes of the system was activated. Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all missiles from firing: In the trash can nearest the main computer, you should be able to get a crumpled piece of paper with a grid of random numbers printed onto it. You will know that it is the right piece of paper if there are the same number of rows and columns in the grid. Find the sequence of consecutive rows where the difference of the sum of the elements of the odd-numbered rows from the sum of the elements in the even-numbered rows are maximum. Get the first number in the first row of the sequence, then the second element of the second row in the sequence, and so on until the corresponding element in the last row in the sequence. Enter these numbers on the main computer and run away as fast as you can. Being fast is very important as it will minimize your chances of getting caught. Luckily, you can bring with you on the mission a small computer which can run a program to look for the palindromic number for you. Good luck on your mission! FORMAT FOR THE INPUT The first line of the input is an integer, n, where n is the number of rows and columns of the grid. Then there will be n succeeding lines with each with n digits separated by spaces. RESTRICTIONS 0 <= n <= 2000 0 <= d <= 1000 for each digit d in the grid It is guaranteed that each test case would only have one quartet that satisfies the conditions needed. Your solution should have a log-linear (O(nlogn) worst-case time complexity. You are allowed to have at most one loop with O(n^2) time. The rest of your program/functions should all be below or equal to O(nlogn). FORMAT FOR THE INPUT One line for each number in the activation code.
PYTHON PROGRAMMING!!
EXTRA CONSTRAINT: MAKE SURE THAT THE CODE ACCEPTS THE INPUT ON THE IMAGE AND OUTPUTS THE RESULT ON THE IMAGE AS WELL
You find yourself in a top-secret mission to infiltrate and disable the nuclear missile silos of a terrorist organization threatening to destroy any country that refuses to surrender. Fortunately, an ally double agent was able to successfully hijack the launch system used by the terrorists. However, in order to not get found out, they could not disable the system outright but they were able to infect the system with an undetectable virus that stops all processes of the system was activated.
Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all missiles from firing:
- In the trash can nearest the main computer, you should be able to get a crumpled piece of paper with a grid of random numbers printed onto it. You will know that it is the right piece of paper if there are the same number of rows and columns in the grid.
- Find the sequence of consecutive rows where the difference of the sum of the elements of the odd-numbered rows from the sum of the elements in the even-numbered rows are maximum.
- Get the first number in the first row of the sequence, then the second element of the second row in the sequence, and so on until the corresponding element in the last row in the sequence.
- Enter these numbers on the main computer and run away as fast as you can.
Being fast is very important as it will minimize your chances of getting caught. Luckily, you can bring with you on the mission a small computer which can run a program to look for the palindromic number for you. Good luck on your mission!
FORMAT FOR THE INPUT
The first line of the input is an integer, n, where n is the number of rows and columns of the grid.
Then there will be n succeeding lines with each with n digits separated by spaces.
RESTRICTIONS
0 <= n <= 2000
0 <= d <= 1000 for each digit d in the grid
It is guaranteed that each test case would only have one quartet that satisfies the conditions needed.
Your solution should have a log-linear (O(nlogn) worst-case time complexity.
You are allowed to have at most one loop with O(n^2) time. The rest of your program/functions should all be below or equal to O(nlogn).
FORMAT FOR THE INPUT
One line for each number in the activation code.
![Sample Input 1
10
90
19
45
88
18
32
12
89
27
36
68
24
96
57
80
73
45
11
56
73
95
39
21
8
83
93
65
56
85
34
64 96 23 3
19
7.
12
59
67
40
15
46
44
50
58
66
33
42
20
67
3 95 75 19
34
34
98
65
30
9
49 10 55 54
62
98
7
25
97
20
9
74
75
100
79
100
70
71
2
35
47
58
79
94
41
6
31
94
95
34
21
58
17
2
78
12
27
Sample Output 1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F50530471-3d1d-446c-af31-a941cdfd5635%2F6c066c9d-a7d9-4588-982e-9fa6e36a723b%2Fbvhy09_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)