← Home
For problem statement at 0-999/100-199/160-169/166/problemB.txt this is a correct solution, but verifier at 0-999/100-199/160-169/166/verifierB.go ends with case 2 failed: expected YES got NO
input:
4
920 1085
915 920
1080 915
1085 1080
8
937 1074
937 1070
934 1067
930 1067
927 1070
927 1074
930 1077
934 1077
exit status 1 can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

type Point struct {
	x, y int64
}

func cross(o, a, b Point) int64 {
	return (a.x-o.x)*(b.y-o.y) - (a.y-o.y)*(b.x-o.x)
}

func isInside(poly []Point, p Point) bool {
	n := len(poly)
	if cross(poly[0], poly[1], p) >= 0 {
		return false
	}
	if cross(poly[0], poly[n-1], p) <= 0 {
		return false
	}
	lo, hi := 1, n-1
	for hi-lo > 1 {
		mid := (lo + hi) >> 1
		if cross(poly[0], poly[mid], p) < 0 {
			lo = mid
		} else {
			hi = mid
		}
	}
	if cross(poly[lo], poly[hi], p) >= 0 {
		return false
	}
	return true
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(in, &n)
	A := make([]Point, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &A[i].x, &A[i].y)
	}
	fmt.Fscan(in, &m)
	B := make([]Point, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &B[i].x, &B[i].y)
	}
	for _, p := range B {
		if !isInside(A, p) {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}
```