Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll=unsigned long long;
- int main(){
- int x[3],y[3],r[3],o[3],n;bool b=1;vector<pair<int,pair<int,int>>>d(3),d1(3);
- vector<pair<int,int>>co;
- cin>>n;
- cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2];
- co.push_back({x[0],y[0]});
- co.push_back({x[1],y[1]});
- co.push_back({x[2],y[2]});
- sort(co.begin(),co.end());
- d[0].first=(co[1].first-co[0].first)*(co[1].first-co[0].first)+(co[1].second-co[0].second)*(co[1].second-co[0].second);
- d[1].first=(co[2].first-co[1].first)*(co[2].first-co[1].first)+(co[2].second-co[1].second)*(co[2].second-co[1].second);
- d[2].first=(co[2].first-co[0].first)*(co[2].first-co[0].first)+(co[2].second-co[0].second)*(co[2].second-co[0].second);
- d[0].second={co[1].first-co[0].first,co[1].second-co[0].second};
- d[1].second={co[2].first-co[1].first,co[2].second-co[1].second};
- d[2].second={co[2].first-co[0].first,co[2].second-co[0].second};
- sort(d.begin(),d.end());
- for(int i=0;i<n-1;++i){
- cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2];
- co.clear();
- co.push_back({x[0],y[0]});
- co.push_back({x[1],y[1]});
- co.push_back({x[2],y[2]});
- sort(co.begin(),co.end());
- d1[0].first=(co[1].first-co[0].first)*(co[1].first-co[0].first)+(co[1].second-co[0].second)*(co[1].second-co[0].second);
- d1[1].first=(co[2].first-co[1].first)*(co[2].first-co[1].first)+(co[2].second-co[1].second)*(co[2].second-co[1].second);
- d1[2].first=(co[2].first-co[0].first)*(co[2].first-co[0].first)+(co[2].second-co[0].second)*(co[2].second-co[0].second);
- d1[0].second={co[1].first-co[0].first,co[1].second-co[0].second};
- d1[1].second={co[2].first-co[1].first,co[2].second-co[1].second};
- d1[2].second={co[2].first-co[0].first,co[2].second-co[0].second};
- sort(d1.begin(),d1.end());
- if((d[0].first==d[1].first || d[1].first==d[2].first) &&(d1[0].first==d1[1].first || d1[1].first==d1[2].first) && (d1[1].first==d[1].first))
- continue;
- r[0]=(d[0].second.first*d[1].second.second-d[0].second.second*d[1].second.first);
- o[0]= (d1[0].second.first*d1[1].second.second-d1[0].second.second*d1[1].second.first);
- r[1]=(d[0].second.first*d[2].second.second-d[0].second.second*d[2].second.first);
- o[1]= (d1[0].second.first*d1[2].second.second-d1[0].second.second*d1[2].second.first);
- r[2]=(d[1].second.first*d[2].second.second-d[1].second.second*d[2].second.first);
- o[2]= (d1[1].second.first*d1[2].second.second-d1[1].second.second*d1[2].second.first);
- if(r[0]*o[0]<0 ||r[1]*o[1]<0 ||r[2]*o[2]<0 || d[0].first!=d1[0].first || d[1].first!=d1[1].first || d[2].first!=d1[2].first)b=0;
- }
- if(b)cout<<"YES";
- else cout<<"NO";
- }
Advertisement
Add Comment
Please, Sign In to add comment