平面上有n条线段,询问某两条线段是否直接或间接相连。
才发现以前写的线段相交模板中没有处理共线但不相交的情况,现在加上了。
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define N 10005
using namespace std;
typedef long long LL;
struct point
{
LL x , y;
point (LL x = 0 , LL y = 0): x(x) , y(y) {};
void input() {cin >> x >> y;}
bool operator < (const point& r) const{
if (x == r.x)
return y < r.y;
return x < r.x;}
bool operator == (const point& r) const{
return x == r.x && y == r.y;
}
};
point operator + (point a , point b) { return point(a.x + b.x , a.y + b.y);}
point operator - (point a , point b) { return point(a.x - b.x , a.y - b.y);}
LL Cross(point a , point b) {return a.x * b.y - a.y * b.x;}
double length(point a) {return