This documentation is automatically generated by competitive-verifier/competitive-verifier
 geometry/is_intersect_cs.hpp
 geometry/is_intersect_cs.hpp#include "geometry/is_intersect_cs.hpp" geometry/base.hpp
 geometry/base.hpp geometry/circle.hpp
 geometry/circle.hpp geometry/line.hpp
 geometry/line.hpp geometry/point.hpp
 geometry/point.hpp geometry/projection.hpp
 geometry/projection.hpp geometry/segment.hpp
 geometry/segment.hpp#include "base.hpp"
#include "circle.hpp"
#include "point.hpp"
#include "projection.hpp"
#include "segment.hpp"
namespace geometry {
int is_intersect_cs(const Circle& c, const Segment& l) {
  Point h = projection(l, c.p);
  if (sign(norm(h - c.p) - norm(c.r)) > 0) return 0;
  auto d1 = abs(c.p - l.a), d2 = abs(c.p - l.b);
  if (sign(c.r - d1) >= 0 && sign(c.r - d2) >= 0) return 0;
  if (sign(c.r - d1) < 0 && sign(d2 - c.r) > 0 ||
      sign(d1 - c.r) > 0 && sign(c.r - d2) < 0)
    return 1;
  if (sign(dot(l.a - h, l.b - h)) < 0) return 2;
  return 0;
}
}  // namespace geometry
#line 2 "geometry/base.hpp"
namespace geometry {
using Real = double;
const Real EPS = 1e-8;
const Real PI = acos(static_cast<Real>(-1));
enum { OUT, ON, IN };
inline int sign(const Real& r) { return r <= -EPS ? -1 : r >= EPS ? 1 : 0; }
inline bool equals(const Real& a, const Real& b) { return sign(a - b) == 0; }
}  // namespace geometry
#line 3 "geometry/point.hpp"
namespace geometry {
using Point = complex<Real>;
istream& operator>>(istream& is, Point& p) {
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}
ostream& operator<<(ostream& os, const Point& p) {
  return os << real(p) << " " << imag(p);
}
Point operator*(const Point& p, const Real& d) {
  return Point(real(p) * d, imag(p) * d);
}
// rotate point p counterclockwise by theta rad
Point rotate(Real theta, const Point& p) {
  return Point(cos(theta) * real(p) - sin(theta) * imag(p),
               sin(theta) * real(p) + cos(theta) * imag(p));
}
Real cross(const Point& a, const Point& b) {
  return real(a) * imag(b) - imag(a) * real(b);
}
Real dot(const Point& a, const Point& b) {
  return real(a) * real(b) + imag(a) * imag(b);
}
bool compare_x(const Point& a, const Point& b) {
  return equals(real(a), real(b)) ? imag(a) < imag(b) : real(a) < real(b);
}
bool compare_y(const Point& a, const Point& b) {
  return equals(imag(a), imag(b)) ? real(a) < real(b) : imag(a) < imag(b);
}
using Points = vector<Point>;
}  // namespace geometry
#line 3 "geometry/circle.hpp"
namespace geometry {
struct Circle {
  Point p;
  Real r{};
  Circle() = default;
  Circle(const Point& p, const Real& r) : p(p), r(r) {}
};
using Circles = vector<Circle>;
}  // namespace geometry
#line 2 "geometry/projection.hpp"
#line 3 "geometry/line.hpp"
namespace geometry {
struct Line {
  Point a, b;
  Line() = default;
  Line(const Point& a, const Point& b) : a(a), b(b) {}
  Line(const Real& A, const Real& B, const Real& C) {  // Ax+By=C
    if (equals(A, 0)) {
      assert(!equals(B, 0));
      a = Point(0, C / B);
      b = Point(1, C / B);
    } else if (equals(B, 0)) {
      a = Point(C / A, 0);
      b = Point(C / A, 1);
    } else if (equals(C, 0)) {
      a = Point(0, C / B);
      b = Point(1, (C - A) / B);
    } else {
      a = Point(0, C / B);
      b = Point(C / A, 0);
    }
  }
  friend ostream& operator<<(ostream& os, Line& l) {
    return os << l.a << " to " << l.b;
  }
  friend istream& operator>>(istream& is, Line& l) { return is >> l.a >> l.b; }
};
using Lines = vector<Line>;
}  // namespace geometry
#line 5 "geometry/projection.hpp"
namespace geometry {
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
Point projection(const Line& l, const Point& p) {
  auto t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + (l.a - l.b) * t;
}
}  // namespace geometry
#line 3 "geometry/segment.hpp"
namespace geometry {
struct Segment : Line {
  Segment() = default;
  using Line::Line;
};
using Segments = vector<Segment>;
}  // namespace geometry
#line 6 "geometry/is_intersect_cs.hpp"
namespace geometry {
int is_intersect_cs(const Circle& c, const Segment& l) {
  Point h = projection(l, c.p);
  if (sign(norm(h - c.p) - norm(c.r)) > 0) return 0;
  auto d1 = abs(c.p - l.a), d2 = abs(c.p - l.b);
  if (sign(c.r - d1) >= 0 && sign(c.r - d2) >= 0) return 0;
  if (sign(c.r - d1) < 0 && sign(d2 - c.r) > 0 ||
      sign(d1 - c.r) > 0 && sign(c.r - d2) < 0)
    return 1;
  if (sign(dot(l.a - h, l.b - h)) < 0) return 2;
  return 0;
}
}  // namespace geometry