线性分类器line
#include<iostream>
using namespace std;
const int N = 1e3;
struct site
{
int x;
int y;
char ch;
}s[N], s1[N], s2[N];
int main()
{
int n, m, j = 0, k = 0, temp[20];
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> s[i].x >> s[i].y >> s[i].ch;
if (s[i].ch == 'A')
{
s1[j] = s[i];
j++;
}
else
{
s2[k] = s[i];
k++;
}
}
for (int i = 0; i < m; i++)
{
int q1, q2, q3;
int t1 = 0, t2 = 0, t3 = 0, t4 = 0, bl1, bl2;
cin >> q1 >> q2 >> q3;
for (int a = 0; a < j; a++)
{
if (!t1)
{
t1 = q1 + q2*s1[a].x + q3* s1[a].y;
if (t1>0)t1 = 1;
else t1 = -1;
continue;
}
t2 = q1 + q2*s1[a].x + q3* s1[a].y;
if (t2>0)t2 = 1;
else t2 = -1;
if (t1!=t2)
{
bl1 = 0;
break;
}
else bl1 = 1;
}
for (int b = 0; b < k; b++)
{
if (!t3)
{
t3 = q1 + q2*s2[b].x + q3* s2[b].y;
if (t3<0)t3 = -1;
else t3 = 1;
continue;
}
t4 = q1 + q2*s2[b].x + q3* s2[b].y;
if (t4>0)t4 = 1;
else t4 = -1;
if (t3!=t4)
{
bl2 = 0;
break;
}
else bl2 = 1;
}
if (bl1 == 1&&bl2 == 1)
temp[i] = 1;
else temp[i] = 0;
}
for (int i = 0; i < m; i++)
if (temp[i] == 1)
cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}