CCF 202006-1 线性分类器

28 篇文章 0 订阅
#include<iostream>
#include<algorithm>
#include<string.h>
#include<cstdio>
using namespace std;
const int maxn = 5e4 + 100;
#define TLE ios::sync_with_stdio(0),cin.tie(0)
const int INF = 0x3f3f3f3f;
int x[maxn], y[maxn];
char s[maxn];
int main() {
	TLE;
	int n, m, a, b, c;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> s[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		int A, B, t = 1;
		if ((a + b * x[0] + c * y[0] > 0&&s[0] == 'A')
			|| (a + b * x[0] + c * y[0] < 0 && s[0] == 'B'))
			A = 1, B = -1;
		else A = -1, B = 1;
		for (int j = 1; j < n; j++) {
			if (s[j] == 'A') {
				if (((a + b * x[j] + c * y[j]) * A) > 0)
					t++;
				else break;
			}
			else if (s[j] == 'B') {
				if (((a + b * x[j] + c * y[j]) * B) > 0)
					t++;
				else break;
			}
		}
		if (n == t) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值