思路:
- 题意需要判断给出的几何图形是左手还是右手(给出的点序可逆时针可顺时针)。
- 思路很简单,就是先找到第边(最长边),然后利用叉积判断小拇指或大拇指与边的位置关系即可。
代码实现:
#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair<int, int>
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int inf = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-2;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
int t, r;
struct node{
double x,y;
}a[25];
double dist(node a, node b){
return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
}
double multi(node a, node b, node c){
return (a.x-c.x)*(b.y-c.y) - (b.x-c.x)*(a.y-c.y);
}
signed main()
{
IOS;
cin>>t;
while(t --){
for(int i = 1; i <= 20; i ++) cin >> a[i].x >> a[i].y;
a[21] = a[1]; a[22] = a[2]; r = 0;
for(int i = 1; i <= 20; i ++){
if(fabs(dist(a[i], a[i+1]) - 81) <= eps){
if(fabs(dist(a[i+1], a[i+2]) - 64) <= eps && multi(a[i], a[i+1], a[i+2]) > 0){
r=1;
break;
}
if(fabs(dist(a[i+1], a[i+2]) - 36) <= eps && multi(a[i], a[i+1], a[i+2]) < 0){
r=1;
break;
}
}
}
cout << (r ? "right" : "left") << endl;
}
return 0;
}