【算法练习】CSP--202006-1--线性分类器

#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll n, m, t_0, t_1, t_2;
struct point
{
	ll x, y;
	char s,aws;
};

int main() {
	cin >> n >> m;
	vector<point>vec(n);

	for (size_t i = 0; i < n; i++)
	{
		cin >> vec[i].x >> vec[i].y >> vec[i].s;
	}

	for (size_t i = 0; i < m; i++)
	{
		cin >> t_0 >> t_1 >> t_2;

		// 计算结果
		for (auto& it : vec)
		{
			ll res = t_0 + t_1 * it.x + t_2 * it.y;
			if (res > 0) it.aws = 'A';
			else it.aws = 'B';
		}
		// 二分类情况统计
		ll sum_score = 0;
		for (auto& it : vec)
		{
			sum_score += (it.s == it.aws);
		}
		// 结果检查
		if (sum_score == 0 || sum_score == n) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值