逻辑有点混乱
#include<iostream>
using namespace std;
struct Point
{
int x;
int y;
char type;
};
struct Inquire
{
int a;
int b;
int c;
};
int main() {
int n, m;
cin >> n >> m;
Point * p = new Point[n];
Inquire * quire = new Inquire[m];
bool type1 = false;
bool type2 = false;
int* a = new int[n]();
int* b = new int[n]();
for (int i = 0; i < n; i++)
{
cin >> p[i].x >> p[i].y >> p[i].type;
}
for (int j = 0; j < m; j++)
{
cin >> quire[j].c >> quire[j].a >> quire[j].b;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
int result = quire[i].a * p[j].x + quire[i].b * p[j].y + quire[i].c;
if (p[j].type == 'A') {
if (result > 0)
a[j] = 2;
else if (result < 0) {
a[j] = 1;
}
}
else if (p[j].type == 'B') {
if (result > 0)
b[j] = 2;
else if (result < 0) {
b[j] = 1;
}
}
}
int typeA = 0;
int typeB = 0;
for (int k = 0; k < n; k++) {
if (a[k] != 0) {
if (typeA == 0) {
typeA = a[k];
type1 = true;
}
else {
if (typeA == a[k])
type1 = true;
else {
type1 = false;
break;
}
}
}
}
for (int k = 0; k < n; k++) {
if (b[k] != 0) {
if (typeB == 0) {
typeB = b[k];
type2 = true;
}
else {
if (typeB == b[k])
type2 = true;
else {
type2 = false;
break;
}
}
}
}
if (type1 == true && type2 == true)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
CSP 2020-06-01 线性分类器
最新推荐文章于 2023-02-23 21:14:46 发布