其他分享
首页 > 其他分享> > 202006 csp认证

202006 csp认证

作者:互联网

-1.

#include<iostream>
#include<vector>
using namespace std;
int n;
int m;
class Point{
public:
    int x;
    int y;
    char flag;
};
class Linear{
public:
    int c;
    int a;
    int b;
};
//检查是否在一边
int isSame1(Point p1,Point p2,Linear l1){
if(l1.a*p1.x+l1.c>-l1.b*p1.y&&l1.a*p2.x+l1.c>-l1.b*p2.y) return 1;
else if(l1.a*p1.x+l1.c<-l1.b*p1.y&&l1.a*p2.x+l1.c<-l1.b*p2.y) return 1;
else   return 0;
}
//检查类别是否相同
int isSame2(Point p1,Point p2){
    if(p1.flag==p2.flag) return 1;
    return 0;
}
int main(){
cin>>n>>m;
vector<Point> v1;
vector<Linear> v2;

//输入
for(int i=0;i<n;i++){
    int x,y;
    char flag;
    cin>>x>>y>>flag;
    Point p={x,y,flag};
    v1.push_back(p);
}
for(int i=0;i<m;i++){
    int c,a,b;
    cin>>c>>a>>b;
    Linear l = {c,a,b};
    v2.push_back(l);

}
//检查两点之间的关系
for(int j=0;j<m;j++){
    int flag = 1;
    //标记分类是否正确
    for(int i=0;i<n;i++){
            for(int k=i+1;k<n;k++){
                if(isSame1(v1[i],v1[k],v2[j])){
                 if(!isSame2(v1[i],v1[k])) {
                           flag = 0;
                    }
                }
            }

  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 }
 return 0;
}

标签:p2,p1,Linear,Point,int,认证,202006,l1,csp
来源: https://www.cnblogs.com/ljmmm1/p/15611934.html