N-Queen (Area)
Time limit1sMemory limit1024 MB
Place N non-attacking queens on an N by N grid warped inside a convex quadrilateral to maximize the total area of the occupied cells.
- Level
Hard8 of 10
- Topics
- Backtracking, Geometry, Bit manipulation
- Solved
- No attempts yet
Problem
The N-Queen problem asks you to place queens on an chess board so that no two queens attack each other. A queen can attack other pieces on the same row, column, or diagonal.
In this problem, the chess board is distorted. The board is a convex quadrilateral ABCD, as shown in the figure. Each of the four sides is divided into equal parts. Division points on segments AB and CD, and on AD and BC, are connected to the points that face them. This forms square cells.

Among all placements of queens where no two queens attack each other, find the placement that maximizes the total area of the cells occupied by queens. Output that maximum total area.
Input
The first line contains .
The second line contains the coordinates of the four vertices , separated by spaces. The vertices are given in clockwise or counterclockwise order.
Output
Print the maximum total area of the cells occupied by queens. Answers with an absolute or relative error of up to are accepted.
Constraints
- . It is guaranteed that a placement of queens exists in this range.
- All input values are integers.