hdu 2108 Shape of HDU(判定是不是凸多边形)

时间:2023-03-08 20:00:19
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e5 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; const double eps = 1e-;
#define _sign(x)((x)>eps?1:((x)<-eps?2:0)) struct point
{
double x,y;
}p[maxn]; double xmult(point p1,point p2,point p0) {
return(p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
} int is_convex(int n) {
int i,s[]={,,};
for (i=;i<n&&s[]|s[];i++)
s[_sign(xmult(p[(i+)%n],p[(i+)%n],p[i]))] = ;
return s[]|s[];
} int main(){
Faster;
int n;
while(cin >> n){
if(n == )
break;
for(int i = ;i < n;i++){
cin >> p[i].x >> p[i].y;
}
if(is_convex(n)){
cout << "convex" << endl;
}
else
cout << "concave" << endl;
}
return ;
}