Problem p02294 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#pragma warning(disable : 4996)
using namespace std;
// ------ Defines ------ //
#define Point complex<long double>
#define px real()
#define py imag()
// ------ Classes ------ //
class Segment {
public:
  Point p1, p2;
  Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Segment(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Segment &s1, const Segment &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Segment &s1, const Segment &s2) {
    return !(s1 == s2);
  }
};
class Line {
public:
  Point p1, p2;
  Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Line(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Line &s1, const Line &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0, b = p2 - p0;
  if (crs(a, b) > 1e-8)
    return 1;
  if (crs(a, b) < -1e-8)
    return -1;
  if (dot(a, b) < -1e-8)
    return 2;
  if (norm(a) < norm(b))
    return -2;
  return 0;
}
bool its(Point p1, Point p2, Point p3, Point p4) {
  return ((ccw(p1, p2, p3) * ccw(p1, p2, p4)) <= 0 &&
          (ccw(p3, p4, p1) * ccw(p3, p4, p2)) <= 0);
}
bool its(Segment s1, Segment s2) { return its(s1.p1, s1.p2, s2.p1, s2.p2); }
// ------ Main ------ //
int q, xp1, yp1, xp2, yp2, xq1, yq1, xq2, yq2;
int main() {
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d%d%d%d%d", &xp1, &yp1, &xp2, &yp2, &xq1, &yq1, &xq2, &yq2);
    printf("%d\\n",
           (its(Segment(xp1, yp1, xp2, yp2), Segment(xq1, yq1, xq2, yq2)) ? 1
                                                                          : 0));
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
using namespace std;
// ------ Defines ------ //
#define Point complex<long double>
#define px real()
#define py imag()
// ------ Classes ------ //
class Segment {
public:
  Point p1, p2;
  Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Segment(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p1x, p2y)){};
  friend bool operator==(const Segment &s1, const Segment &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Segment &s1, const Segment &s2) {
    return !(s1 == s2);
  }
};
class Line {
public:
  Point p1, p2;
  Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Line(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p1x, p2y)){};
  friend bool operator==(const Line &s1, const Line &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
Point prj(const Segment &a, const Point &b) {
  Point c = a.p2 - a.p1;
  return a.p2 + c * dot(b - a.p1, norm(c));
}
Point rfl(const Segment &a, const Point &b) {
  return b + (prj(a, b) - b) * 2.0L;
}
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0, b = p2 - p0;
  if (crs(a, b) > 1e-10)
    return 1;
  if (crs(a, b) < -1e-10)
    return -1;
  if (dot(a, b) < -1e-10)
    return 2;
  if (norm(a) < norm(b))
    return -2;
  return 0;
}
bool its(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
          ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool its(Segment s1, Segment s2) { return its(s1.p1, s1.p2, s2.p1, s2.p2); }
// ------ Main ------ //
int q, xp1, yp1, xp2, yp2, xq1, yq1, xq2, yq2;
int main() {
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d%d%d%d%d%d", &xp1, &yp1, &xp2, &yp2, &xq1, &yq1, &xq2, &yq2);
    printf("%d\\n", its(Segment(xp1, yp1, xp2, yp2), Segment(xq1, yq1, xq2, yq2))
                       ? 1
                       : 0);
  }
  return 0;
}