permitted to alter the marks through the accompanying activity:    Pick two particular integers I and j among 1 and n.    Trade the marks of focuses I and j, lastly    Draw the section between focuses I and j.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 You are permitted to alter the marks through the accompanying activity: 

 

Pick two particular integers I and j among 1 and n. 

 

Trade the marks of focuses I and j, lastly 

 

Draw the section between focuses I and j. 

 

A grouping of tasks is legitimate if in the wake of applying every one of the activities in the succession all together, the k-th point winds up having the name k for all k among 1 and n comprehensive, and the drawn sections don't meet each other inside. Officially, assuming two of the portions cross, they should do as such at a typical endpoint of the two sections. 

 

Specifically, all drawn portions should be unmistakable. 

 

Track down any legitimate arrangement of activities, or say that none exist. 

 

Input 

 

The main line contains an integer n (3≤n≤2000) — the number of focuses. 

 

The I-th of the accompanying n lines contains three integers xi, yi, man-made intelligence (−106≤xi,yi≤106, 1≤ai≤n), addressing that the I-th point has arranges (xi,yi) and at first has mark simulated intelligence. 

 

It is ensured that all focuses are unmistakable, no three focuses are collinear, and the marks a1,a2,… ,a structure a change of 1,2,… ,n. 

 

Output 

 

In case it is difficult to play out a substantial arrangement of activities, print −1. 

 

In any case, print an integer k (0≤k≤n(n−1)2) — the number of activities to perform, trailed by k lines, each containing two integers I and j (1≤i,j≤n, i≠j) — the lists of the focuses picked for the activity.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning