• CCF--线性分类器


    #include<iostream>
    using namespace std;
    
    int n = 1000;
    struct point{
        int x;
        int y;
        char type;
    }point;
    
    
    
    int main(){
    
        int  m, x, y, theta1, theta2, theta3;
        char c;
        cin >> n >> m;
        struct point arr[n];
        for(int i = 0; i < n; i++){
            cin >> arr[i].x >> arr[i].y >> arr[i].type;
        }
    
        for(int i = 0; i < m; i++){
            cin >> theta1 >> theta2 >> theta3;
            int flag = 1;
            int a = 0, b = 0, c = 0;
            for(int j = 0; j < n; j++){
    
                if(a == 0 && b == 0){
                    //initiaal
                    if(theta1 + theta2 * arr[j].x + theta3 * arr[j].y > 0){
                        if(arr[j].type == 'A'){
                            a = 1;
                            b = -1;
                        }else{
                            a = -1;
                            b = 1;
                        }
                    }else{
                        if(arr[j].type == 'B'){
                            a = 1;
                            b = -1;
                        }else{
                            a = -1;
                            b = 1;
                        }
                    }
                }else{
    
                    c = (theta1 + theta2 * arr[j].x + theta3 * arr[j].y > 0)? 1: -1;
                    if(arr[j].type == 'A' && c != a){
                        flag = 0;
                        break;
                    }else if(arr[j].type == 'B' && c != b){
                        flag = 0;
                       // cout << "tihsB" << arr[j].x << arr[j].y <<endl;
                        break;
                    }
                }
    
    
            }
    
    
            if(flag){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }
    
    
    
    
  • 相关阅读:
    halcon 2极坐标转笛卡尔坐标
    xmal随笔
    halcon 3焊点查找
    halcon 药丸查找
    halcon 1区域保存生成
    mokee源码下载
    多个DataTable的合并成一个新表
    代码分析工具
    SQL大量数据查询分页存储过程
    sqlite3使用简介
  • 原文地址:https://www.cnblogs.com/yuyuan-bb/p/13632311.html
Copyright © 2020-2023  润新知