cses

My solution for the coding challenges of cses.fi
git clone https://git.tronto.net/cses
Download | Log | Files | Refs | README

point_location_test_2189.cpp (482B)


      1 #include <iostream>
      2 
      3 struct Point {
      4 	long long x;
      5 	long long y;
      6 	Point operator-(const Point& p) const { return Point{x-p.x, y-p.y}; }
      7 	long long operator*(const Point& v) { return x * v.y - y * v.x; }
      8 };
      9 
     10 int main() {
     11 	int t;
     12 	Point a, b, c;
     13 	std::cin >> t;
     14 	for (int i = 0; i < t; i++) {
     15 		std::cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
     16 		auto v = (b-a)*(c-a);
     17 		if (v > 0) std::cout << "LEFT\n";
     18 		else if (v < 0) std::cout << "RIGHT\n";
     19 		else std::cout << "TOUCH\n";
     20 	}
     21 }