@@ -981,18 +981,34 @@ int n;
981981#define nn (x ) (x>=n?x-n:x)
982982const ll mod = 1000000007 ;
983983
984- typedef point pt;
985- typedef double ld;
986984
987- inline bool between (pt a, pt b, pt c)
985+ inline bool between (point a, point b, point c)
988986{
989- ld aa = atan2 (a.y , a.x );
990- ld ab = atan2 (b.y , b.x );
991- ld ac = atan2 (c.y , c.x );
987+ double aa = atan2 (a.y , a.x );
988+ double ab = atan2 (b.y , b.x );
989+ double ac = atan2 (c.y , c.x );
992990 while (ab < aa) ab += 2 * 3.14159265358 ;
993991 while (ac < aa) ac += 2 * 3.14159265358 ;
994992 return ac < ab;
995993}
994+
995+ bool inside_polygon (int j1, int j2, int n, point p[], double area){
996+ // assert(j1 < j2);
997+ /* double area = 0;
998+ * for (int i = 0; i < n; i++) area += p[i] * p[i + 1];
999+ * if (area < 0){
1000+ * reverse(p, p + n);
1001+ * area = -area;
1002+ * }
1003+ * p[n] = p[0];
1004+ */
1005+
1006+ double sq = 0 ;
1007+ for (int i = 0 ; i < j1; i++) sq += p[i] * p[i + 1 ];
1008+ sq += p[j1] * p[j2];
1009+ for (int i = j2; i < n; i++) sq += p[i] * p[i + 1 ];
1010+ return 0 <= sq && sq <= area;
1011+ }
9961012int main (){
9971013 scanf (" %d" , &n);
9981014 clr (can, true );
@@ -1008,24 +1024,17 @@ int main(){
10081024 {
10091025 reverse (p, p + n);
10101026 p[n] = p[0 ];
1027+ sq = -sq;
10111028 }
10121029
1013- if (p[0 ].x == -744281 ){
1014- cout << 144076085 << endl;
1015- return 0 ;
1016- }
1017-
1018- if (p[0 ].x == -62958 ){
1019- cout << 589057227 << endl;
1020- return 0 ;
1021- }
10221030
10231031
10241032 F (i,0 ,n)
10251033 F (j,i+2 ,n){
10261034 if (i == 0 && j == n-1 ) continue ;
10271035// if (!inside_polygon(p[j], p[i], n, p)){
1028- if (!between (p[j + 1 ] - p[j], p[j - 1 ] - p[j], p[i] - p[j])) {
1036+ if (!inside_polygon (i, j, n, p, sq)){
1037+ // if (!between(p[j + 1] - p[j], p[j - 1] - p[j], p[i] - p[j])) {
10291038// cout << i << ' ' << j << endl;
10301039 can[i][j] = can[j][i] = false ;
10311040 continue ;
0 commit comments