传送门
题意: 标题已经说明了一切
思路: 如果是凹的, 那么一定有两条相邻的边叉乘是负的.. 注意要把任意两条相邻的都判掉. 起点哪!!!
const int maxn = 1e5 + 5;
struct point {
int x, y;
friend int operator * (const point& a, const point& b){
return a.x*b.y - a.y*b.x;
}
bool operator < (const point &_) const {
if(_.x == x) return y < _.y;
return x < _.x;
}
}po[maxn];
point xl(const point& a, const point& b) {
return point{b.x-a.x, b.y-a.y};
}
void solve() {
int n;
while(cin >> n && n) {
for (int i = 1 ; i <= n ; i ++) {
cin >> po[i].x >> po[i].y;
}
int f = 1; po[n+1] = po[1];
for (int i = 2 ; i <= n + 1 ; i ++) {
if (xl(po[i-1], po[i]) * xl(po[i], po[i%n+1]) < 0) {
f = 0;
break;
}
}
printf("%s\n", f ? "convex":"concave");
}
}