Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int paral(pair< int,int > p1,pair< int,int > p2,pair< int,int > p3,pair< int,int > p4){
- int A1=p2.second - p1.second,B1=p1.first - p2.first,C1 = p2.first*p1.second - p1.first*p2.second;
- int A2=p4.second - p3.second,B2=p3.first - p4.first,C2 = p4.first*p3.second - p3.first*p4.second;
- if( (A1*B2 - B1*A2) == 0 ){
- if(A1*B2 == B1*A2 && B1*C2 == B2*C1 && A1*C2 == A2*C1)return 0;
- else return 1;
- }
- return 0;
- }
- int main()
- {
- int n;
- cin>>n;
- for(int i=0;i<n;i++){
- pair< int,int > p1,p2,p3,p4;
- cin>>p1.first>>p1.second>>p2.first>>p2.second>>p3.first>>p3.second>>p4.first>>p4.second;
- if(paral(p1,p2,p3,p4)){
- if(paral(p1,p3,p2,p4) || paral(p1,p4,p2,p3))cout<<"YES"<<endl;
- else cout<<"NO"<<endl;
- }
- else if(paral(p1,p3,p2,p4)){
- if(paral(p1,p2,p3,p4) || paral(p1,p4,p3,p2))cout<<"YES"<<endl;
- else cout<<"NO"<<endl;
- }
- else if(paral(p1,p4,p2,p3)){
- if(paral(p1,p2,p4,p3) || paral(p1,p3,p2,p4))cout<<"YES"<<endl;
- cout<<"NO"<<endl;
- }
- else cout<<"NO"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement