DES: Points that make up the convex polygon are given clockwise. Then there are Q queries that give the number of two points, asking the two-point line to divide the polygon into smaller portions of the area.
After each connection, the polygon is asked to calculate the area time-out. The correct solution is to find the total area of polygon by using the triangular area of the cross-spherical triangle, and to retain the prefix and the polygon. When any two points are connected, just prefix and subtract the area of a triangle.
However... What I don't understand is that the loop about Q ... for is timeout ... while is AC ... Coordinates is clearly interger...int wa...double on AC ...
#include <stdio.h>#include<string.h>#include<iostream>#include<math.h>using namespacestd;structpoint{Doublex, y;} p[50010];DoubleAREAA (Point p0, point P1, point p2)//calculates the area of triangles with vertices of these three points{ Doubletemp = (p1.x-p0.x) * (P2.Y-P0.Y)-(p2.x-p0.x) * (p1.y-p0.y); Temp/=2.0; returnfabs (temp);}Doublearea[50010];//Stores the area of the polygon's prefix polygon. intMain () {intN, Q; intxx, yy; while(~SCANF ("%d%d", &n, &q)) { for(intI=0; i<n; ++i) {scanf ("%LF%LF", &p[i].x, &p[i].y); } DoubleTot_area =0; area[0] =0; area[1] =0; for(intI=1; i<n-1; ++i) {Tot_area+ = AREAA (p[0], P[i], p[i+1]); Area[i+1] =Tot_area; } intT1, T2; Doubleans; DoubleTemp_area; while(q--) {scanf ("%d%d", &t1, &T2); if(T2 > T1) swap (t1, T2);//Guaranteed T1>t2Temp_area = AREA[T1]-AREA[T2]-AREAA (p[0], p[t1], p[t2]); if(Temp_area < tot_area-temp_area) printf ("%.1lf\n", Temp_area); Elseprintf"%.1lf\n", tot_area-Temp_area); } } return 0;}L Oh, oh, K .
Spoj UMR 10A Compute geometry