codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

135B.md (2225B)


      1 Source: https://codeforces.com/problemset/problem/135/B
      2 
      3 B. Rectangle and Square
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case.
     22 
     23 Input
     24 
     25 You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide.
     26 
     27 Output
     28 
     29 Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct.
     30 
     31 If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 0 0  
     39 10 11  
     40 10 0  
     41 0 11  
     42 1 1  
     43 2 2  
     44 2 1  
     45 1 2
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 YES  
     52 5 6 7 8  
     53 1 2 3 4
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 0 0  
     60 1 1  
     61 2 2  
     62 3 3  
     63 4 4  
     64 5 5  
     65 6 6  
     66 7 7
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 NO
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 0 0  
     79 4 4  
     80 4 0  
     81 0 4  
     82 1 2  
     83 2 3  
     84 3 2  
     85 2 1
     86 ```
     87 
     88 Output
     89 
     90 ```
     91 YES  
     92 1 2 3 4  
     93 5 6 7 8
     94 ```
     95 
     96 Note
     97 
     98 Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.