-1

I came to a new type of problem in competitive programming where I have to read n lines of inputs according to the given test cases.

Example input format Example Input

So, how should I read this, can you please explain to me step-by-step? Waiting for a quick and effective solution.

Example Input

2 - (no. of test cases)
STRING1
string2
Huzaifa
  • 93
  • 2
  • 8
  • 1
    First you [`input`](https://docs.python.org/3/library/functions.html#input) the number of test cases from the input stream, then in a loop you read the rest. It cannot get quicker and more effective than that. – bereal Jun 17 '21 at 16:57

1 Answers1

1

It's the same as you solving one test case.

The difference is you should put your logic to solve the problem in for loop for looping T times to handle multiple test cases.

Example:

def solve_the_problem(p):
  # Your logic here

# Number of test cases
T = input()
for x in range(T):
  # Each input for test case
  p = input()
  solve_the_problem(p)
polamokh
  • 36
  • 3