#include <iostream>
using namespace std;
typedef struct
{
int x;
int y;
char type;
}point;
typedef struct
{
int a;
int b;
int c;
}line;
int Judge(line L, point P)
{
int temp = L.a + L.b * P.x + L.c * P.y;
if(temp > 0) return 1;
else return 0;
}
int main()
{
int n, m;
cin >> n >> m;
point *p = new point[n];
for(int i = 0; i < n; i++)
cin >> p[i].x >> p[i].y >> p[i].type;
line *L = new line[m];
for(int i = 0; i < n; i++)
cin >> L[i].a >> L[i].b >> L[i].c;
for(int i = 0; i < m; i++)
{
int out = 0;
char flag_1 = p[0].type;
int flag_2 = Judge(L[i], p[0]);
for(int j = 1; j < n; j++)
{
if(flag_2 == 1)
{
if(Judge(L[i], p[j]) == 1 && p[j].type != flag_1)
{
out = 1;
break;
}
else if(Judge(L[i], p[j]) == 0 && p[j].type == flag_1)
{
out = 1;
break;
}
}
else
{
if(Judge(L[i], p[j]) == 0 && p[j].type != flag_1)
{
out = 1;
break;
}
else if(Judge(L[i], p[j]) == 1 && p[j].type == flag_1)
{
out = 1;
break;
}
}
}
if(out == 0) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
【题解】CCF CSP 202006-1 —— 线性分类器
最新推荐文章于 2024-07-25 17:57:45 发布