PYTHON PROGRAMMING!! 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

PYTHON PROGRAMMING!!

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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
87
32
12
89
27
36
68
24
96
57
82
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
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
31
94
95
34
21
58
17
78
12
27
Sample Output 1
20
9
9
Explanation 1
90 19 45
88 18
12
89 27
87
32
36 68 24 96
95 39 21
34
57
82
80
73
45
11
56
73
8
83
93
65
56
| 96 23
2 59
85
64
3
19
7
12
67
40
15
46
44
50 58
66 33
42
20 67 3
30 9
95
75
19
34
34
98
65
49 10 55
54
62
98
7
25
97
20
74
75
100
79
100
70
71
35
47
58
79
94
41
31
94
95
34
21
58
17
2
78
12
27
2.
2.
Transcribed Image Text:Sample Input 1 10 90 19 45 88 18 87 32 12 89 27 36 68 24 96 57 82 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 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 31 94 95 34 21 58 17 78 12 27 Sample Output 1 20 9 9 Explanation 1 90 19 45 88 18 12 89 27 87 32 36 68 24 96 95 39 21 34 57 82 80 73 45 11 56 73 8 83 93 65 56 | 96 23 2 59 85 64 3 19 7 12 67 40 15 46 44 50 58 66 33 42 20 67 3 30 9 95 75 19 34 34 98 65 49 10 55 54 62 98 7 25 97 20 74 75 100 79 100 70 71 35 47 58 79 94 41 31 94 95 34 21 58 17 2 78 12 27 2. 2.
Sample Input 0
10
23
16
25
12
19
11
8
1
4
3
6
7
20
18
24
4
17
5
7
3
4
6 1
Sample Output 0
10
11
Explanation 0
10
23
16
25
12
19
11
8
4
3
9
7
18
24
4
17
5
4 6
7
3
1
20
9,
Transcribed Image Text:Sample Input 0 10 23 16 25 12 19 11 8 1 4 3 6 7 20 18 24 4 17 5 7 3 4 6 1 Sample Output 0 10 11 Explanation 0 10 23 16 25 12 19 11 8 4 3 9 7 18 24 4 17 5 4 6 7 3 1 20 9,
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY