GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday, 3 July 2022

[Solution] Segmentation Fault CodeChef Solution | Codechef Solution


There are N people numbered from 1 to N such that:

  • Exactly one of these people is a thief and always lies;
  • All the others are honest and always tell the truth.

If the ith person claims that the thief is one person out of Li,Li+1,Li+2,,Ri, determine how many people could be the thief.

It is guaranteed that at least one person can be the thief.

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

  • First line of each test case will contain N, the number of people. N lines follow.
  • The ith line contains two space-separated integers - Li and Ri, the range of people amongst

  •  which the ith person claims the thief is.

Output Format

  • For each test case, in the first line, output K, the number of possible thieves.
  • In the next K lines, output the list of people that could be the thieves, in ascending order.

Constraints

  • 1T105
  • 3N105
  • 1LiRiN
  • Sum of N over all test cases does not exceed 105.
  • It is guaranteed that at least one person can be the thief.

No comments:

Post a Comment