zoukankan      html  css  js  c++  java
  • 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;
            }
        }
    }
    
    
    
    
  • 相关阅读:
    列表推导式,生成器表达式
    迭代器,生成器初始
    装饰器的进阶
    函数名用途,初始装饰器
    函数参数,和空间
    py文件的操作
    字符串相关操作
    python基础二
    Django简介
    Django初识
  • 原文地址:https://www.cnblogs.com/yuyuan-bb/p/13632311.html
Copyright © 2011-2022 走看看