Can read about orientation here Idea comes from the slope comparison. #include <iostream> #include <algorithm> #include <cstdio> #include <vector> #include <cmath> using namespace std; struct point{ double x,y; }; vector<point>pp; double area(int n,vector<point> arr) { double ans = 0.0; for(int i=0;i<n;i++) { ans += (arr[i].x*arr[(i+1)%n].y – arr[i].y*arr[(i+1)%n].x); } return fabs(ans/2.0); } int checkCross(point p, point
Category: Computational Geometry
11122
It took me long time to get accepted. Needs some geometric knowledge, used graham scan algorithm, can be done also without using that, but most importantly made me crazy to figure out the special cases. So the coding was not well formatted. Adding some special input cases for the problem. #include <iostream> #include <cstdio> #include