AlexNeagu11

Point Location Test

Mar 19th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. struct point {
  5. int x, y;
  6. void read() {
  7. cin >> x >> y;
  8. }
  9. void write() {
  10. cout << x << ' ' << y << '\n';
  11. }
  12. point operator - (const point &B) const {
  13. return point{x - B.x, y - B.y};
  14. }
  15. void operator -= (const point &B) {
  16. x -= B.x;
  17. y -= B.y;
  18. }
  19. int operator * (const point &B) const {
  20. return x * B.y - y * B.x;
  21. }
  22. int orientation(const point &A, const point &B) const {
  23. return (A - *this) * (B - *this);
  24. }
  25. int dist(point A) {
  26. A -= *this;
  27. return A.x * A.x + A.y * A.y;
  28. }
  29. bool operator <(const point &A) {
  30. if(x == A.x) {
  31. return y < A.y;
  32. }
  33. return x < A.x;
  34. }
  35.  
  36. };
  37.  
  38.  
  39. int32_t main() {
  40.  
  41. int T;
  42. cin >> T;
  43. while(T--) {
  44. point P1, P2, P3;
  45. P1.read();
  46. P2.read();
  47. P3.read();
  48. P2 -= P1;
  49. P3 -= P1;
  50. int orientation = P3 * P2;
  51. if(orientation == 0) cout << "TOUCH\n";
  52. else if(orientation < 0) cout << "LEFT\n";
  53. else cout << "RIGHT\n";
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment