fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7. int main() {
  8. int x1=0;
  9. int y1=0;
  10. int x2=1;
  11. int y2=1;
  12. int x3=0;
  13. int y3=1;
  14. int x4=1;
  15. int y4=0;
  16.  
  17. std::vector<double> vec;
  18. vec.push_back(sqrt((double)((x2- x1)*(x2-x1) + (y2-y1)*(y2-y1))));
  19. vec.push_back(sqrt((double)((x2- x3)*(x2-x3) + (y2-y3)*(y2-y3))));
  20. vec.push_back(sqrt((double)((x4- x3)*(x4-x3) + (y4-y3)*(y4-y3))));
  21. vec.push_back(sqrt((double)((x4- x1)*(x4-x1) + (y4-y1)*(y4-y1))));
  22. vec.push_back(sqrt((double)((x4- x2)*(x4-x2) + (y4-y2)*(y4-y2))));
  23. vec.push_back(sqrt((double)((x3- x1)*(x3-x1) + (y3-y1)*(y3-y1))));
  24.  
  25. std::sort(vec.begin(),vec.end());
  26.  
  27.  
  28. if(vec[0]==vec[3])
  29. {
  30. std::cout<<"Test"<<std::endl;
  31. double sqrt1 = sqrt(vec[0]*vec[0]+vec[1]*vec[1]);
  32. double sqrt2 = sqrt(vec[2]*vec[2]+vec[3]*vec[3]);
  33. /*
  34.   std::cout<<"vec[4] ="<<vec[4]<<std::endl;
  35.   std::cout<<"sqrt1 = "<<sqrt1<<std::endl;
  36.   */
  37. if(vec[4]==sqrt1 && vec[5] == sqrt2)
  38. {
  39. std::cout<<"YES"<<std::endl;
  40. return 0;
  41. }
  42. }
  43.  
  44. std::cout<<"NO";
  45. return 0;
  46. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Test
NO