#MyCode n = int(input("Input the size of the matrix: ")) list1 = [] #To store the sum of each row list2 = [] #To store the indexes of odd rows list3 = [] #To store the remainders ...to compare and find the largest one matrix = [[0] * n for row in range(0, n)] for x in range(0, n):     line = list(map(int, input().split()))    #To take input in a sequence     for y in range(0, n):         matrix[x][y] = line[y]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python

need help, I need to perfect the testcases

I will be pasting here my code for easy reference. 

The given problem is in the photo I will attach

will give thumbs up if I perfect the testcases thank you!

#MyCode

n = int(input("Input the size of the matrix: "))

list1 = [] #To store the sum of each row
list2 = [] #To store the indexes of odd rows
list3 = [] #To store the remainders ...to compare and find the largest one

matrix = [[0] * n for row in range(0, n)]
for x in range(0, n):

    line = list(map(int, input().split()))    #To take input in a sequence

    for y in range(0, n):
        matrix[x][y] = line[y]

i = 0
while(i!=n):
    
    add =0
    for j in range(0,n):
        add = add + matrix[i][j]              # adding each element in a row
    list1.append(add)                         #apending each value to the list1
    i=i+1

# Odd Indexes

for i in range(0,n):              
    
    if(i%2 == 0):
        list2.append(i)

#Storing remainders

for i in range(0,len(list2)):
    
    element1 = list2[i]
    element2 = list1[i+1]
    element3 = list1[element1]
    rem =  element3 - element2
    list3.append(rem)


#finding the largest remainder
largest=list3[0]
index=0
for i in range(0,len(list3)):
    
    if(list3[i]>largest):
        largest = list3[i]
        index = i
element = list2[index]

print("\n")
print(matrix[0][index])
print(matrix[1][index+1])
print(matrix[2][index+2])

TESTCASE #0
TESTCASE #1
Testcase 0 X
Testcase 1 X
Testcase 0 X
Testcase 1 X
Your code did not pass this test case.
Your code did not pass this test case.
Input (stdin)
Input (stdin)
10
10
23
16
25
12
90
19
45
88
18
87
32
12
89
27
19
11
8
4
36
68
24
96
57
82
80
73
45
11
3
6
9
7
20
18
24
4
17
56
73
95
39
21
8
83
93
65
56
85
34
64
96
23
3
19
7
12
59
7
3
4
6
1
67
40
15
46
44
50
58
66
33
42
20
67
3
95
75
19
34
34
98
65
Your Output (stdout)
30
9.
49
10
55
54
62
98
7
25
Input the size of the matrix:
97
20
9
74
75
100
79
100
70
71
2
35
47
58
79
94
41
6
31
10
94
95
34
21
58
17
2
78
12
27
11
9
Your Output (stdout)
Input the size of the matrix:
Expected Output
10
45
11
96
21
Compiler Message
Expected Output
20
Wrong Answer
9
Compiler Message
Wrong Answer
Transcribed Image Text:TESTCASE #0 TESTCASE #1 Testcase 0 X Testcase 1 X Testcase 0 X Testcase 1 X Your code did not pass this test case. Your code did not pass this test case. Input (stdin) Input (stdin) 10 10 23 16 25 12 90 19 45 88 18 87 32 12 89 27 19 11 8 4 36 68 24 96 57 82 80 73 45 11 3 6 9 7 20 18 24 4 17 56 73 95 39 21 8 83 93 65 56 85 34 64 96 23 3 19 7 12 59 7 3 4 6 1 67 40 15 46 44 50 58 66 33 42 20 67 3 95 75 19 34 34 98 65 Your Output (stdout) 30 9. 49 10 55 54 62 98 7 25 Input the size of the matrix: 97 20 9 74 75 100 79 100 70 71 2 35 47 58 79 94 41 6 31 10 94 95 34 21 58 17 2 78 12 27 11 9 Your Output (stdout) Input the size of the matrix: Expected Output 10 45 11 96 21 Compiler Message Expected Output 20 Wrong Answer 9 Compiler Message Wrong Answer
Given:
Input, Constraints, Output
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
Input Format
The first line of the input is an integer, n, where n is the number of rows and columns of the grid.
virus that stops all processes of the system was activited.
Then there will be n succeeding lines with each with n digits separated by spaces.
Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all
missiles from firing:
Constraints
0 <n < 2000
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.
0 < d< 1000 for each digit d in the grid.
It is guaranteed that each test case would only have sequence that satisifies the conditions needed.
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 .
Your soltuion should have a log-linear (O(n log n)) worst-case time complexity.
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.
(11 March 2022) Additional notes and clarifications: you are allowed to have at most one loop with O(n2)
time. The rest of your program/functions should all be below or equal to O(m log n). Failure to meet these
4. Enter these numbers on the main computer and run away as fast as you can.
constraints would result in a 50% decution for your grade in this activity.
Output Format
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
One line for each number in the activation code.
luck on your mission!
Transcribed Image Text:Given: Input, Constraints, Output 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 Input Format The first line of the input is an integer, n, where n is the number of rows and columns of the grid. virus that stops all processes of the system was activited. Then there will be n succeeding lines with each with n digits separated by spaces. Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all missiles from firing: Constraints 0 <n < 2000 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. 0 < d< 1000 for each digit d in the grid. It is guaranteed that each test case would only have sequence that satisifies the conditions needed. 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 . Your soltuion should have a log-linear (O(n log n)) worst-case time complexity. 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. (11 March 2022) Additional notes and clarifications: you are allowed to have at most one loop with O(n2) time. The rest of your program/functions should all be below or equal to O(m log n). Failure to meet these 4. Enter these numbers on the main computer and run away as fast as you can. constraints would result in a 50% decution for your grade in this activity. Output Format 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 One line for each number in the activation code. luck on your mission!
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education