zoukankan      html  css  js  c++  java
  • CSP_2020061_线性分类器

    题目描述

    #include <iostream>
    #include <vector>
    #include <set> 
    #include <algorithm>
    #include <unordered_map>
    #include <string>
    #include <cstring>
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    
    int main() {
    	int n, query_times;
    	vector<pair<int,int>> points; // {<x,y>, <x,y>}
    	vector<char> type;
    	bool a_above; // > 0
    	
    	cin >> n >> query_times;
    	for (int i = 0; i < n; i++) {
    		int x, y;
    		char c;
    		cin >> x >> y;
    		cin >> c;
    		auto pair = make_pair(x,y);
    		points.push_back(pair);
    		type.push_back(c);
    	}
    	for (int i = 0; i < query_times; i++) {
    		int a, b, c; // a + bx + cy 
    		cin >> a >> b >> c;
    		int w = a + b * points[0].first + c * points[0].second;
    		if (type[0] == 'A') {
    			a_above = (w > 0);
    		} else {
    			a_above = !(w > 0);
    		}
    		bool flag = true;
    		for (int j = 0; j < n; j++) {
    			w = a + b * points[j].first + c * points[j].second;
    			bool above = (w>0);
    			if (type[j] == 'A' && above != a_above) {
    				flag = false;
    				break;
    			} else if (type[j] == 'B' && above != !(a_above)){
    				flag = false;
    				break;
    			} else {
    				// pass
    			}
    		}
    		if (flag) cout << "Yes" << endl;
    		else cout << "No" << endl;
    	}
    	return 0;
    }
    
  • 相关阅读:
    SJTU T4143 推箱子
    Markdown基本语法
    命令行的操作——cd
    C++ ------- 类和对象
    数据结构------栈和队列
    MySQL------ 子查询
    MySQL------ SQL99语法
    C++------内存分区模型
    第三章------数据链路层
    MySQL------ SQL92语法
  • 原文地址:https://www.cnblogs.com/ticlab/p/15642618.html
Copyright © 2011-2022 走看看