试题编号: | 202006-1 |
试题名称: | 线性分类器 |
时间限制: | 1.0s |
内存限制: | 512.0MB |
问题描述: | ![](https://img-blog.csdnimg.cn/direct/a1696370019c44af96908b4d910f4936.png) ![](https://img-blog.csdnimg.cn/direct/50518a8c77e14b29bbaafc8370ebf83c.png) ![](https://img-blog.csdnimg.cn/direct/590226498ca540c3b97748ac8b797080.png) |
import java.util.*;
public class Main {
static class State{
int x;
int y;
public State(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
State[] A=new State[n];
int an=0;
State[] B=new State[n];
int bn=0;
for(int i=0;i<n;i++){
int xx=in.nextInt();
int yy=in.nextInt();
String lei=in.next();
if(lei.equals("A")){
State s1=new State(xx,yy);
A[an]=s1;
an++;
}else{
State s2=new State(xx,yy);
B[bn]=s2;
bn++;
}
}
for(int i=0;i<m;i++){
int a0=in.nextInt();
int a1=in.nextInt();
int a2=in.nextInt();
int aa=0;
boolean ll=true;
for(int j=0;j<an;j++){
int num=a0+a1*A[j].x+a2*A[j].y;
if(j==0){
if(num<0){
aa=-1;
}else{
aa=1;
}
}else{
if(num*aa<0){
ll=false;
break;
}
}
}
if(!ll){
System.out.println("No");
continue;
}
for(int j=0;j<bn;j++){
int num=a0+a1*B[j].x+a2*B[j].y;
if (num * aa > 0) {
ll = false;
break;
}
}
if(!ll){
System.out.println("No");
}else{
System.out.println("Yes");
}
}
}
}