Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int paral(pair< int,int > p1,pair< int,int > p2,pair< int,int > p3,pair< int,int > p4){
  6.  
  7. int A1=p2.second - p1.second,B1=p1.first - p2.first,C1 = p2.first*p1.second - p1.first*p2.second;
  8.  
  9. int A2=p4.second - p3.second,B2=p3.first - p4.first,C2 = p4.first*p3.second - p3.first*p4.second;
  10.  
  11. if( (A1*B2 - B1*A2) == 0 ){
  12. if(A1*B2 == B1*A2 && B1*C2 == B2*C1 && A1*C2 == A2*C1)return 0;
  13. else return 1;
  14. }
  15.  
  16. return 0;
  17. }
  18.  
  19. int main()
  20. {
  21. int n;
  22. cin>>n;
  23. for(int i=0;i<n;i++){
  24. pair< int,int > p1,p2,p3,p4;
  25. cin>>p1.first>>p1.second>>p2.first>>p2.second>>p3.first>>p3.second>>p4.first>>p4.second;
  26. if(paral(p1,p2,p3,p4)){
  27. if(paral(p1,p3,p2,p4) || paral(p1,p4,p2,p3))cout<<"YES"<<endl;
  28. else cout<<"NO"<<endl;
  29. }
  30. else if(paral(p1,p3,p2,p4)){
  31. if(paral(p1,p2,p3,p4) || paral(p1,p4,p3,p2))cout<<"YES"<<endl;
  32. else cout<<"NO"<<endl;
  33. }
  34. else if(paral(p1,p4,p2,p3)){
  35. if(paral(p1,p2,p4,p3) || paral(p1,p3,p2,p4))cout<<"YES"<<endl;
  36. cout<<"NO"<<endl;
  37. }
  38. else cout<<"NO"<<endl;
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement