202006-1线性分类器@TOC
题目
代码
代码如下(示例):
<font color=#999AAA >代码如下(示例):
#include <iostream>
using namespace std;
struct Node{
int x;
int y;
char type;
int Pos;
}node[1005];
struct Parameter{
int p1;
int p2;
int p3;
}pm[25];
int main (){
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
cin >> node[i].x >> node[i].y >> node[i].type;
}
for(int i = 0; i < m; i++){
cin >> pm[i].p1 >> pm[i].p2 >> pm[i].p3;
}
for(int i = 0; i < m; i++){
bool flag = true;
for(int j = 0; j < n; j++){
int temp = pm[i].p1 + pm[i].p2 * node[j].x + pm[i].p3 * node[j].y;
if(temp < 0){
node[j].Pos = -1;
}
else{
node[j].Pos = 1;
}
if(j == 0)
continue;
if((node[j].Pos == node[j-1].Pos && node[j].type != node[j-1].type)
||(node[j].Pos != node[j-1].Pos && node[j].type == node[j-1].type)){
cout << "No" << endl;
flag = !flag;
break;
}
}
if(flag){
cout << "Yes" << endl;
}
}
return 0;
//一遍过;
}