为什么ac23 wa3(random_01 random_02 random_20)啊。
#include <bits/stdc++.h>
using namespace std;
const long double ERR=1e-10;
struct point
{
long double x, y;
} a[200005], b[200005];
long double cross(point p0, point p1, point p2)
{
return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
}
long long n, m, i, low, high, mid;
int main()
{
scanf("%lld", &n);
for (i = n - 1; i >= 0; --i) cin>>a[i].x>>a[i].y;
scanf("%lld", &m);
for (i = 0; i < m; ++i) cin>>b[i].x>>b[i].y;
for (i = 0; i < m; ++i)
{
if (cross(a[0], a[1], b[i]) >ERR || cross(a[0], a[n - 1], b[i]) < -ERR)
{
printf("OUT\n");
continue;
}
if (abs(cross(a[0], a[1], b[i]))<ERR || abs(cross(a[0], a[n - 1], b[i]))<ERR)
{
printf("ON\n");
continue;
}
low = 2;
high = n - 1;
while (low < high)
{
mid = (low + high) >> 1;
if (cross(a[0], a[mid], b[i]) >= 0)
high = mid;
else
low = mid + 1;
}
if (abs(cross(a[low], a[low - 1], b[i])) < ERR)
{
printf("ON\n");
continue;
}
if (cross(a[low], a[low - 1], b[i]) <-ERR)
{
printf("OUT\n");
continue;
}
printf("IN\n");
}
return 0;
}