Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #include <math.h>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- struct ipn{
- ll x,y;
- };
- struct rpn{
- db x,y;
- };
- rpn rVec(rpn A, rpn B){
- rpn ab;
- ab.x = A.x - B.x;
- ab.y = A.y - B.y;
- return ab;
- }
- ipn iVec(ipn A, ipn B){
- ipn ab;
- ab.x = B.x - A.x;
- ab.y = B.y - A.y;
- return ab;
- }
- rpn div(rpn A, rpn B, db p, db q){
- rpn res;
- res.x = (q * A.x + p * B.x) / (p + q);
- res.y = (q * A.y + p * B.y) / (p+q);
- return res;
- }
- db dot(rpn a, rpn b){
- return a.x * b.x + a.y * b.y;
- }
- db lgth(rpn a){
- return sqrt(a.x * a.x + a.y * a.y);
- }
- db angl(rpn a, rpn b){
- db an = acos(dot(a, b) / ( lgth(a) * lgth(b)) );
- return an;
- }
- db rCross(rpn a, rpn b){
- return a.y * b.x - a.x * b.y;
- }
- ll iCross(ipn a, ipn b){
- return a.y * b.x - a.x * b.y;
- }
- int anglTp(rpn A, rpn B, rpn C){ //возвращает тип угла между AB и AC то есть угла BAC
- rpn ab = rVec(A, B);
- rpn ac = rVec(A, C);
- if (dot(ab, ac) > 0){
- return 1; //острый
- }
- if (dot(ab, ac) == 0){
- return 1;//прямой
- }
- return 2; // тупой
- }
- db rArea(rpn A, rpn B, rpn C){
- rpn ab = rVec(A, B);
- rpn ac = rVec(A, C);
- return fabs( rCross(ab, ac) ); // 2.0
- }
- db hgt(rpn A, rpn B, rpn C){ //height
- db h;
- //cout<<"rArea(B, A, C) = "<<rArea(B, A, C) <<"\n";
- //cout<<"AB = "<<lgth(rVec(A, B))<<"\n";
- h = rArea(B, A, C) / lgth( rVec(A, B) );
- //cout<<"h = "<<h<<"\n";
- if ( anglTp(A, B, C) == 2){
- //cout<<"one\n";
- return lgth( rVec(C, A) );
- }
- if (anglTp (B, A, C) == 2){
- //cout<<"two\n";
- return lgth( rVec(C, B) );
- }
- return h;
- }
- void mk(rpn &x){
- cin>>x.x>>x.y;
- }
- void mk(ipn &x){
- cin>>x.x>>x.y;
- }
- db eps = 1e-7;
- /*int sgn(db x){
- if (x > 0.0) return 1;
- else if (x == 0.0) return 0;
- return -1;
- }*/
- int sgn(ll x){
- if (x > 0) return 1;
- else if (x == 0) return 0;
- return -1;
- }
- bool eq(rpn A, rpn B){
- return A.x == B.x && A.y == B.y;
- }
- bool eq(ipn A, ipn B){
- return A.x == B.x && A.y == B.y;
- }
- bool rInter(rpn A, rpn B, rpn C, rpn D){
- if (eq(A,C) || eq(A,D ) || eq(B, C) || eq(B,D)){
- return 1;
- }
- if (A.x > B.x) swap(A, B);
- if (C.x > D.x) swap(C, D);
- if (B.x < C.x) {
- //cout<<"one\n";
- return 0;
- }
- if (D.x < A.x) {
- //cout<<"two\n";
- return 0;
- }
- if (A.y > B.y) swap(A, B);
- if (C.y > D.y) swap(C, D);
- if (B.y < C.y) return 0;
- if (D.y < A.y ) return 0;
- if ( sgn(rCross(rVec(A,B), rVec(C,D)) == 0) ){
- return 1;
- }
- if (sgn(rCross(rVec(A,B), rVec(A,C))) == sgn(rCross(rVec(A,B), rVec(A,D)))){
- /*cout<<"three\n";
- //сout<<"sgn(rCross(rVec(A,B), rVec(A,C))) = "<<sgn(rCross(rVec(A,B), rVec(A,C)))<<"\n";
- cout<<"sgn(rCross(rVec(A,B), rVec(A,C))) = "<<sgn(rCross(rVec(A,B), rVec(A,C)))<<"\n";
- cout<<"sgn(rCross(rVec(A,B), rVec(A,D))) = "<<sgn(rCross(rVec(A,B), rVec(A,D)))<<"\n";*/
- return 0;
- }
- if (sgn(rCross(rVec(C,D), rVec(C, A))) == sgn(rCross(rVec(C, D), rVec(C,B)))){
- /*cout<<"four\n";
- cout<<"sgn(rCross(rVec(C,D), rVec(C, A))) = "<<sgn(rCross(rVec(C,D), rVec(C, A)))<<"\n";
- cout<<"sgn(rCross(rVec(C, D), rVec(C,B))) = "<<sgn(rCross(rVec(C, D), rVec(C,B)))<<"\n";*/
- return 0;
- }
- return 1;
- }
- bool iInter(ipn A, ipn B, ipn C, ipn D){
- if (eq(A,C) || eq(A,D ) || eq(B, C) || eq(B,D)){
- return 1;
- }
- if (A.x > B.x) swap(A, B);
- if (C.x > D.x) swap(C, D);
- if (B.x < C.x) {
- //cout<<"one\n";
- return 0;
- }
- if (D.x < A.x) {
- //cout<<"two\n";
- return 0;
- }
- if (A.y > B.y) swap(A, B);
- if (C.y > D.y) swap(C, D);
- if (B.y < C.y) return 0;
- if (D.y < A.y ) return 0;
- if ( sgn(iCross(iVec(A,B), iVec(C,D)) == 0) ){
- return 1;
- }
- if (sgn(iCross(iVec(A,B), iVec(A,C))) == sgn(iCross(iVec(A,B), iVec(A,D)))){
- /*cout<<"three\n";
- //сout<<"sgn(rCross(rVec(A,B), rVec(A,C))) = "<<sgn(rCross(rVec(A,B), rVec(A,C)))<<"\n";
- cout<<"sgn(rCross(rVec(A,B), rVec(A,C))) = "<<sgn(rCross(rVec(A,B), rVec(A,C)))<<"\n";
- cout<<"sgn(rCross(rVec(A,B), rVec(A,D))) = "<<sgn(rCross(rVec(A,B), rVec(A,D)))<<"\n";*/
- return 0;
- }
- if (sgn(iCross(iVec(C,D), iVec(C, A))) == sgn(iCross(iVec(C, D), iVec(C,B)))){
- /*cout<<"four\n";
- cout<<"sgn(rCross(rVec(C,D), rVec(C, A))) = "<<sgn(rCross(rVec(C,D), rVec(C, A)))<<"\n";
- cout<<"sgn(rCross(rVec(C, D), rVec(C,B))) = "<<sgn(rCross(rVec(C, D), rVec(C,B)))<<"\n";*/
- return 0;
- }
- return 1;
- }
- void sh(ipn x){
- cout<<x.x<<' '<<x.y<<"\n";
- }
- void one_sd( ipn C,ipn A, ipn B, ipn D){ //точки C и D лежат по одну сторону от AB
- /*cout<<"C A B D\n";
- sh(C);
- sh(A);
- sh(B);
- sh(D);*/
- if (sgn(iCross(iVec(A,B), iVec(A, C))) != 0 && sgn(iCross(iVec(A,B), iVec(A, D))) != 0){
- if (sgn(iCross(iVec(A,B), iVec(A, C))) != sgn(iCross(iVec(A,B), iVec(A, D))) ){
- cout<<"No\n";
- exit(0);
- }
- }
- if (sgn(iCross(iVec(A,B), iVec(B, C))) != 0 && sgn(iCross(iVec(A,B), iVec(B,D))) != 0){
- if (sgn(iCross(iVec(A,B), iVec(B,C))) != sgn(iCross(iVec(A,B), iVec(B,D)))){
- cout<<"No\n";
- exit(0);
- }
- }
- /*
- */
- /*if (sgn(iCross(iVec(C, D), iVec(C,A))) != sgn(iCross(iVec(C, D), iVec(C, B))) ){
- cout<<"No\n";
- exit(0);
- }*/
- //if (sgn(iCross(iVec(A,B), iVec())))
- //cout<<"\n\n";
- }
- void sh(rpn a){
- cout<<a.x<<' '<<a.y<<"\n";
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cout.precision(20);
- int n; cin>>n;
- vector <ipn> v(n);
- for (int i = 0; i < n;++i){
- mk(v[i]);
- }
- //if (n == 3){
- // cout<<"Yes\n";
- // exit(0);
- //}
- //cout<<"\n\n";
- //one_sd(v[n-1], v[0], v[1], v[2]);
- for (int i = 0; i < n;++i){
- one_sd(v[i], v[(i+1)%n], v[(i+2)%n], v[(i+3)%n]);
- }
- cout<<"Yes\n";
- }
- /*
- 15
- 3 5
- 3 16
- 18 16
- 18 3
- 7 3
- 7 13
- 11 11
- 14 13
- 12 7
- 9 10
- 9 5
- 16 5
- 16 15
- 5 15
- 5 3
- 5
- 2 2
- 2 6
- 5 9
- 8 6
- 10 1
- 5
- 2 2
- 2 6
- 5 4
- 8 6
- 10 1
- 4
- 1 1
- 1 3
- 3 3
- 3 1
- */
Add Comment
Please, Sign In to add comment