#include using namespace std; typedef long long ll; typedef long double ld; struct point { int x, y; point(){} point(int a,int b){ x = a; y = b; } bool operator !=(point s) { if(x!=s.x) return x!=s.x; return y!=s.y; } bool operator <(point s) { if(x!=s.x) return xb.x){ D=-1; swap(a,b); } if(a.x!=b.x) { slope = (1.0*b.y-a.y)/(1.0*b.x-a.x); C = a.y - slope * a.x; slope *= D;//// C *= D; } } }; vector pol1,pol2; vector in1,out1,in2,out2; bool cmp1(event a, event b) { if(a.a!=b.a) return a.a>t; for(int tc = 0 ; tc< t;tc++) { set S; pol1.clear(); pol2.clear(); in1.clear(); in2.clear(); out1.clear(); out2.clear(); cin >> n; int mnx1=1e9+2,mnx2=1e9+2,mxx1 = -1e9-2,mxx2 = -1e9-2; for (int i = 1; i <= n; i++) { int x, y; scanf("%d%d", &x, &y); mnx1 = min(mnx1,x); mxx1 = max(mxx1,x); pol1.push_back(point(x, y)); S.insert(x); if (i > 1) push(1, event(pol1[i - 2], pol1[i - 1])); if (i == n) push(1, event(pol1[i - 1], pol1[0])); } cin >> m; for (int i = 1; i <= m; i++) { int x, z; scanf("%d%d", &x, &z); mnx2=min(mnx2,x); mxx2=max(mxx2,x); // x+=100;z+=100; pol2.push_back(point(x, z)); S.insert(x); if (i > 1) push(2, event(pol2[i - 2], pol2[i - 1])); if (i == m) push(2, event(pol2[i - 1], pol2[0])); } // cout< segs; for (auto u : S) segs.push_back(u); int pin1 = 0, pin2 = 0, pout1 = 0, pout2 = 0, X1 = segs[0]; ld slopes1 = 0, Cs1 = 0; ld slopes2 = 0, Cs2 = 0; ld ans = 0; for (int i = 0; i < segs.size(); i++) { int X2 = segs[i]; while (pin1 < in1.size() && in1[pin1].a.x <= X1) { slopes1 += in1[pin1].slope; Cs1 += in1[pin1].C; pin1++; } while (pin2 < in2.size() && in2[pin2].a.x <= X1) { slopes2 += in2[pin2].slope; Cs2 += in2[pin2].C; pin2++; } while (pout1 < out1.size() && out1[pout1].b.x <= X1) { slopes1 -= out1[pout1].slope; Cs1 -= out1[pout1].C; pout1++; } while (pout2 < out2.size() && out2[pout2].b.x <= X1) { slopes2 -= out2[pout2].slope; Cs2 -= out2[pout2].C; pout2++; } ans += F(slopes1, Cs1, slopes2, Cs2, X2) - F(slopes1, Cs1, slopes2, Cs2, X1); X1 = X2; } cout << fixed; cout.precision(10); cout << ans << endl; //assert(ans<=1e18); assert(ans>=0); } return 0; }