标签:ios space lov contest tps while als creat com
先判断给定点是顺时针还是逆时针,然后再判断长度为6的边是在长度为9的边的左边还是右边即可
// Created by CAD
#include <bits/stdc++.h>
using namespace std;
bool judge(vector<double> x,vector<double> y,int n){
if(n < 3) return 0.0>0;
double s = y[0] * (x[n - 1] - x[1]);
x.resize(n+1),y.resize(n+1);
y[n] = y[0],x[n]=x[0];
for(int i = 1; i < n; ++ i)
s += y[i] * (x[i - 1] - x[i + 1]);
return s * 0.5>0;
}
double dis(double x1,double y1,double x2,double y2){
return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n=20;
int t;cin>>t;
while(t--){
vector<double> x(20),y(20);
for(int i=0;i<n;++i)
cin>>x[i]>>y[i];
if(!judge(x,y,n))
reverse(x.begin(),x.end()),reverse(y.begin(),y.end());
bool f1=0,f2=0,ans=0;
double eps=1;
for(int i=0;i<n;++i){
double a=dis(x[i],y[i],x[(i+1)%n],y[(i+1)%n]);
double b=dis(x[(i+1)%n],y[(i+1)%n],x[(i+2)%n],y[(i+2)%n]);
if(abs(a-36)<=eps&&abs(b-81)<=eps)
ans=1;
}
if(ans) cout<<"right"<<endl;
else cout<<"left"<<endl;
}
return 0;
}
标签:ios space lov contest tps while als creat com
原文地址:https://www.cnblogs.com/CADCADCAD/p/13338854.html