202006-1 线性分类器

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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值