Expected distance of point from polygon

0

0 votes
Medium
Problem

You are given a Simple Polygon P in XY plane with n vertices, given in clockwise OR anticlockwise order, and a point p in the same plane.
All the vertices of P and point p have integer coordinates.

A point q is chosen uniformly randomly inside the polygon. Find the expected euclidean distance of q from p

Input

  • The first line contains n, the number of vertices of polygon P.

  • The next line contains two integers (x0,y0), the coordinates of point p

  • ith of the next n lines contains two integers (xi,yi), the coordinates of ith vertex of polygon.

Output
Print only one line containing the expected distance of a point randomly chosen inside P from p, rounded to the nearest integer.

Constraints

  • n105

  • 0xi,yi106, for all 0in

  • All points in the input are distinct.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The expected distance of center of a square of length 4 from a point chosen randomly inside it is 1.5304

Editor Image

?