202006-1 线性分类器
一条线把若干点分成两部分,那么肯定是一部分点在线上,代入直接方程后,大于0,一部分点在线下,代入直线方程后,小于0
#include <stdio.h>
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
void pt(){ cout<<'\n';}
template<class H, class ... T> void pt(H h,T... t){ cout<<" "<<h; pt(t...);}
const int maxn = 1e6+10;
int N,M;
struct node{
ll x,y; char tag;
}p[maxn];
void solve(){
ll t1,t2,t3;
int cnt1 = 0,cnt2 = 0,cnt3 = 0,cnt4 = 0;
scanf("%lld %lld %lld",&t1,&t2,&t3);
for(int i = 1;i<=N;i++){
if(t1 + t2 * p[i].x + t3 * p[i].y > 0){
if(p[i].tag == 'A') cnt3++;
else cnt4++;
}else{
if(p[i].tag == 'A') cnt1++;
else cnt2++;
}
}
if((cnt1 && cnt2) || (cnt3 && cnt4)) puts("No");
else puts("Yes");
}
int main(){
cin>>N>>M;
for(int i = 1;i<=N;i++) scanf("%lld %lld %c",&p[i].x,&p[i].y,&p[i].tag);
while(M--){
solve();
}
return 0;
}