Advertisement
Saleh127

UVA 11800

May 24th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5.  
  6. struct point{
  7.  
  8. ll x,y;
  9. };
  10.  
  11. point c[200];
  12.  
  13.  
  14. double dal(point a, point b)
  15. {
  16. return (double)(b.y-a.y)/(double)(b.x-a.x);
  17. }
  18.  
  19. ll dis(point a,point b)
  20. {
  21. return ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  22. }
  23.  
  24. bool check(point a,point b,point c)
  25. {
  26. ll dall=(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
  27.  
  28. return dall>0;
  29. }
  30.  
  31. void swapp(point &a,point &b)
  32. {
  33. point ss;
  34. ss=a;
  35. a=b;
  36. b=ss;
  37. }
  38.  
  39. void sortt()
  40. {
  41. for(ll i=0;i<=3;i++)
  42. {
  43. if(check(c[0],c[1],c[2])==1)
  44. {
  45. if(check(c[1],c[2],c[3])==1)
  46. {
  47. if(check(c[0],c[1],c[3])==1)
  48. {
  49. break;
  50. }
  51. else swapp(c[1],c[3]);
  52. }
  53. else swapp(c[2],c[3]);
  54. }
  55. else swapp(c[1],c[2]);
  56. }
  57. }
  58.  
  59.  
  60. int main()
  61. {
  62. ios_base::sync_with_stdio(0);
  63. cin.tie(0);cout.tie(0);
  64.  
  65.  
  66.  
  67. test
  68. {
  69. for(ll i=0;i<4;i++)
  70. {
  71. cin>>c[i].x>>c[i].y;
  72. }
  73.  
  74. sortt();
  75.  
  76. ll a,b,cc,d,e,f;
  77.  
  78. a=dis(c[0],c[1]);
  79. b=dis(c[1],c[2]);
  80. cc=dis(c[2],c[3]);
  81. d=dis(c[0],c[3]);
  82. e=dis(c[0],c[2]);
  83. f=dis(c[1],c[3]);
  84.  
  85. cout<<"Case "<<cs<<": ";
  86.  
  87. if(a==b && b==cc && cc==d)
  88. {
  89. if(e==f) cout<<"Square"<<endl;
  90. else cout<<"Rhombus"<<endl;
  91. }
  92.  
  93. else if(a==cc && b==d && cc!=d)
  94. {
  95. if(e==f) cout<<"Rectangle"<<endl;
  96. else cout<<"Parallelogram"<<endl;
  97. }
  98.  
  99. else
  100. {
  101. if((dal(c[0],c[1])==dal(c[3],c[2])) || (dal(c[0],c[3])==dal(c[1],c[2])))
  102. {
  103. cout<<"Trapezium"<<endl;
  104. }
  105. else cout<<"Ordinary Quadrilateral"<<endl;
  106. }
  107. }
  108. return 0;
  109. }
  110.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement