Answer to Question #277039 in Python for magama

Question #277039

The first line contains two integers N and P, the number of researchers and the number of pairs. Each of the next P lines contains 2 space-separated integers denoting researcher ID's with the same nationality. The researchers are numbered 0 through N-1. the researcher is from a different country which only have one researcher. It could be multi countries that only have one researcher.

For example,

4 2
1 2
2 3

The first line contains N and P information which is 4 researchers and 2 pairs of researchers. researchers by country are [0] (which is not it found in pair list) and [1,2,3]. There are 3 pairs to choose from: [0,1],[0,2] and [0,3].

Input Format

The first line contains two integers N and P, the number of researchers and the number of pairs.

Each of the next P lines contains 2 space-separated integers denoting researcher ID's with the same nationality.

Constraints

  • 1 <= N <= 105
  • 1 <= P <= 104






1
Expert's answer
2021-12-08T16:30:42-0500
n, p = map(int, input('Enter N and P: ').split())
n = list(range(1, n))
for i in range(p):
   print(n[i], n[i + 1])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS