This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub ebi-fly13/icpc_library
#define PROBLEM \ "https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/1/CGL_1_C" #include "../../geometry/base_ld.hpp" #include "../../template/template.hpp" using namespace lib; int main() { std::cout << std::fixed << std::setprecision(15); long double x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; vec p0(x1, y1), p1(x2, y2); int q; std::cin >> q; while (q--) { double x, y; std::cin >> x >> y; int flag = isp(p0, p1, vec(x, y)); std::string ans; if (flag == 1) { ans = "COUNTER_CLOCKWISE"; } else if (flag == -1) { ans = "CLOCKWISE"; } else if (flag == -2) { ans = "ONLINE_BACK"; } else if (flag == 2) { ans = "ONLINE_FRONT"; } else { ans = "ON_SEGMENT"; } std::cout << ans << std::endl; } }
#line 1 "test/geometry/Counter_Clockwise.test.cpp" #define PROBLEM \ "https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/1/CGL_1_C" #line 2 "geometry/base_ld.hpp" #line 2 "template/template.hpp" #include <bits/stdc++.h> #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() using ll = long long; using ld = long double; using ull = unsigned long long; template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } namespace lib { using namespace std; } // namespace lib // using namespace lib; #line 4 "geometry/base_ld.hpp" namespace lib { using vec = complex<ld>; const ld PI = acos(-1); void ldout(int len = 20) { cout << fixed << setprecision(len); } int sgn(ld a, const ld eps = 1e-7) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; } bool same_vec(vec a, vec b) { a -= b; return sgn(a.real()) == 0 && sgn(a.imag()) == 0; } ld dot(const vec &a, const vec &b) { return (conj(a) * b).real(); } ld cross(const vec &a, const vec &b) { return (conj(a) * b).imag(); } int isp(const vec &a, const vec &b, const vec &c) { int cross_sgn = sgn(cross(b - a, c - a)); if (cross_sgn == 0) { if (sgn(dot(b - a, c - a)) < 0) return -2; if (sgn(dot(a - b, c - b)) < 0) return 2; } return cross_sgn; } vec rot90(const vec &a) { return {-a.imag(), a.real()}; } vec rot(const vec &a, ld rad) { return a * vec(cosl(rad), sinl(rad)); } bool comp_for_argument_sort(const vec &lhs, const vec &rhs) { // if (abs(arg(lhs)-arg(rhs)) < eps) return false; // need ? return arg(lhs) < arg(rhs); } } // namespace lib #line 6 "test/geometry/Counter_Clockwise.test.cpp" using namespace lib; int main() { std::cout << std::fixed << std::setprecision(15); long double x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; vec p0(x1, y1), p1(x2, y2); int q; std::cin >> q; while (q--) { double x, y; std::cin >> x >> y; int flag = isp(p0, p1, vec(x, y)); std::string ans; if (flag == 1) { ans = "COUNTER_CLOCKWISE"; } else if (flag == -1) { ans = "CLOCKWISE"; } else if (flag == -2) { ans = "ONLINE_BACK"; } else if (flag == 2) { ans = "ONLINE_FRONT"; } else { ans = "ON_SEGMENT"; } std::cout << ans << std::endl; } }