- Quiz
- AC
- 解説
- 隣り合った2辺についてベクトルを考えて外積が負ならダメ
typedef complex<ld> C; // 外積 ld cross(C a, C b){ return a.real()*b.imag() - a.imag()*b.real(); } // 凸性判定 // https://imagingsolution.net/math/calc_n_point_area/ bool is_convex(vector<C> V){ ll N = V.size(); V.push_back(V[0]); V.push_back(V[1]); rep(i,N){ C a = V[i+1]-V[i]; C b = V[i+2]-V[i+1]; if(cross(a,b)<0) return false; } return true; } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin>>N; vector<C> V; rep(i,N){ ld x,y;cin>>x>>y; V.push_back({x,y}); } if(is_convex(V)){ p(1); }else{ p(0); } return 0; }