1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <iostream> #include <algorithm> #include <map> #include <cstdio> #include <cstdlib> #include <string> #include <unordered_map> #include <vector> using namespace std; int n,m; long long x[1005], y[1005]; char type[1005]; long long theta0,theta1,theta2; bool checkPointPos(long long x,long long y){ return theta0+theta1*x+theta2*y > 0; } bool checkLine(){ char typ = type[0]; bool pos = checkPointPos(x[0], y[0]); for(int i=1;i<n;i++){ if(typ==type[i] && pos!= checkPointPos(x[i], y[i]) || typ!=type[i] && pos== checkPointPos(x[i], y[i])){ return false; } } return true; } int main() { ios::sync_with_stdio(false); cin>>n>>m; for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>type[i]; for(int i=0;i<m;i++){ cin>>theta0>>theta1>>theta2; if(checkLine()){ cout<<"Yes\n"; }else{ cout<<"No\n"; } } } |
CSP 202006-1 线性分类器
发表评论