Language: C++

#include <cassert>
#include <algorithm>
#include <iostream>
#include <complex>
#include <tuple>
#include <vector>
using namespace std;

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

typedef complex<double> point;
double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
	return real(conj(a)*b);
}
int ccw(point a, point b, point c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;  // counter clockwise
	if (cross(b, c) < 0)   return -1;  // clockwise
	if (dot(b, c) < 0)     return +2;  // c--a--b on line
	if (norm(b) < norm(c)) return -2;  // a--b--c on line
	return 0;  // a--c--b on line or a----bc
}

typedef array<point, 2> line;
bool intersectSS(const line& s, const line& t) {
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
			ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
point crosspoint(const line& l, const line& m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (eq(A, 0.) && eq(B, 0.)) return m[0]; // same line
	if (eq(A, 0.)) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
	return m[0] + B / A * (m[1] - m[0]);
}

line read_line() {
	line res;
	for (auto& p : res) {
		int x, y;
		cin >> x >> y;
		p = point(x, y);
	}
	return res;
}

int solve() {
	line new_road = read_line();
	int n;
	cin >> n;
	typedef tuple<point, bool, bool> pinfo;
	vector<pinfo> points;
	for (int i = 0; i < n; i++) {
		line l = read_line();
		bool own, ground;
		cin >> own >> ground;
		if (intersectSS(new_road, l)) {
			points.emplace_back(crosspoint(new_road, l), own, ground);
		}
	}
//	cout << points.size() << endl;
	sort(points.begin(), points.end(), [&new_road](const pinfo& a, const pinfo& b) {
		return abs(get<0>(a) - new_road[0]) < abs(get<0>(b) - new_road[0]);
	});
	bool cur = get<1>(points[0]) ? get<2>(points[0]) : !get<2>(points[0]);
	int cnt = 0;
	for (int i = 1; i < points.size(); i++) {
		if ((get<1>(points[i]) && cur != get<2>(points[i])) ||
			(!get<1>(points[i]) && cur == get<2>(points[i]))) {
			cur = !cur;
			cnt++;
//			cout << i << endl;
		}
	}
	return cnt;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cout << solve() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'bool intersectSS(const line&, const line&)':
a.cc:31:21: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                     ^
a.cc:31:26: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                          ^
a.cc:31:31: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                               ^
a.cc:31:41: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                                         ^
a.cc:31:46: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                                              ^
a.cc:31:51: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   31 |         return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      |                                                   ^
a.cc:32:30: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                              ^
a.cc:32:35: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                                   ^
a.cc:32:40: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                                        ^
a.cc:32:50: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                                                  ^
a.cc:32:55: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                                                       ^
a.cc:32:60: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   32 |                         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
      |                                                            ^
a.cc: In function 'point crosspoint(const line&, const line&)':
a.cc:35:27: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   35 |         double A = cross(l[1] - l[0], m[1] - m[0]);
      |                           ^
a.cc:35:34: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   35 |         double A = cross(l[1] - l[0], m[1] - m[0]);
      |                                  ^
a.cc:35:40: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   35 |         double A = cross(l[1] - l[0], m[1] - m[0]);
      |                                        ^
a.cc:35:47: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   35 |         double A = cross(l[1] - l[0], m[1] - m[0]);
      |                                               ^
a.cc:36:27: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   36 |         double B = cross(l[1] - l[0], l[1] - m[0]);
      |                           ^
a.cc:36:34: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   36 |         double B = cross(l[1] - l[0], l[1] - m[0]);
      |                                  ^
a.cc:36:40: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   36 |         double B = cross(l[1] - l[0], l[1] - m[0]);
      |                                        ^
a.cc:36:47: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   36 |         double B = cross(l[1] - l[0], l[1] - m[0]);
      |                                               ^
a.cc:37:45: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   37 |         if (eq(A, 0.) && eq(B, 0.)) return m[0]; // same line
      |                                             ^
a.cc:39:17: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   39 |         return m[0] + B / A * (m[1] - m[0]);
      |                 ^
a.cc:39:33: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   39 |         return m[0] + B / A * (m[1] - m[0]);
      |                                 ^
a.cc:39:40: error: no match for 'operator[]' (operand types are 'const line' {aka 'const std::array<std::complex<double>, 2>'} and 'int')
   39 |         return m[0] + B / A * (m[1] - m[0]);
      |                                        ^
a.cc: At global scope:
a.cc:42:16: error: return type 'line' {aka 'struct std::array<std::complex<double>, 2>'} is incomplete
   42 | line read_line() {
      |                ^
a.cc: In function 'void read_line()':
a.cc:43:14: error: aggregate 'line res' has incomplete type and cannot be defined
   43 |         line res;
      |              ^~~
a.cc: In function 'int solve()':
a.cc:53:14: error: variable 'line new_road' has initializer but incomplete type
   53 |         line new_road = read_line();
      |              ^~~~~~~~
a.cc:59:22: error: variable 'line l' has initializer but incomplete type
   59 |                 line l = read_line();
      |                      ^
a.cc: In lambda function:
a.cc:68:40: error: 'new_road' is not captured
   68 |                 return abs(get<0>(a) - new_road[0]) < abs(get<0>(b) - new_road[0]);
      |                                        ^~~~~~~~
a.cc:67:54: note: the lambda has no capture-default
   67 |         sort(points.begin(), points.end(), [&new_road](const pinfo& a, const pinfo& b) {
      |                                                      ^
a.cc:53:14: note: '<typeprefixerror>new_road' declared here
   53 |         line new_road = read_line();
      |              ^~~~~~~~
a.cc:68:71: error: 'new_road' is not captured
   68 |                 return abs(get<0>(a) - new_road[0]) < abs(get<0>(b) - new_road[0]);
      |                                                                       ^~~~~~~~
a.cc:67:54: note: the lambda has no capture-default
   67 |         sort(points.begin(), points.end(), [&new_road](const pinfo& a, const pinfo& b) {
      |                                                      ^
a.cc:53:14: note: '<typeprefixerror>new_road' declared here
   53 |         line new_road = read_line();
      |              ^~~~~~~~