## Mock CCO '18 Contest 1 Problem 4 - A Rectangle Problem

View as PDF

Points: 25 (partial)
Time limit: 0.18s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given a list of rectangles, compute the minimum perimeter of a polygon with axis-aligned sides such that the first rectangle is contained within the polygon and no point on the perimeter of the polygon lies inside, but not on the perimeter, of any of the rectangles.

#### Constraints

For any rectangle, and

For at most 30% of marks, .

#### Input Specification

The first line will contain a single integer, .

The next lines each contain four integers, , , , and , defining the vertices of one of the rectangles.

Note that the second line of input corresponds to the rectangle that must be contained within the polygon.

#### Output Specification

Output the desired perimeter of the polygon.

#### Sample Input

4
8 4 13 8
2 1 6 7
4 7 9 11
14 7 19 11

#### Sample Output

32