The potato problem
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
A 1-concave polygon is a simple polygon (its sides don't intersect or touch) which has at least 1 concave interior angle.
There are N points on a plane. Let S be the maximum area of a 1-concave polygon with vertices in those points. Compute 2S. Note that if there is no such (1-concave) polygon, you should print -1.
- The first line of the input contains an integer T - the number of test cases.
- The first line of each test case contains N - the number of points.
- Each of the following N lines contains two integers x and y - the coordinates of a point.
If there's no 1-concave polygon, print -1. Otherwise, print one integer: twice the area of the largest one (it's guaranteed to be an integer under these constraints).
- 1 ≤ T ≤ 100
- 3 ≤ N ≤ 105
- No two points coincide (have identical both x and y coordinates).
- No three points are collinear.
- The sum of N over all test cases won't exceed 5·105.
- |x|,|y| ≤ 109
Input: 2 5 2 2 -2 -2 2 -2 -2 2 0 1 3 0 0 1 0 0 1 Output: 28 -1
|Tags||convex-hull, cook68, geometry, medium, two-pointers, xellos0|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions