This question is to give yourself a warning. The template must be very reliable. It turns out that the pattern I’m having may have different OJS issues, is unfortunate in the scene. The essence of the essence
The intro template is king. The essence of the essence (a little worse, only, alas, ~~~~~~~~~~~~~~~~)) Since then, I don’t believe in various patterns on the Internet.
stop symbol.
#include<iostream>
#include<cstdio>
#include<algorithm>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 1504
typedef double datatype;
using namespace std;
//typedef complex<double> point;
struct point {
datatype x, y;
point(){}
point(datatype _x, datatype _y):x(_x),y(_y){}
point(const point &temp)
{
x = temp.x;
y = temp.y;
}
}fir[MAXN],sec[MAXN];
datatype cmp(datatype x)
{
if (x > 0)return 1;
if (x < 0)return -1;
return 0;
}
point start,end;
datatype cross(const point &p1, const point &p2, const point &q1, const point &q2)
{
return cmp((q2.y - q1.y)*(p2.x - p1.x) - (q2.x - q1.x)*(p2.y - p1.y));
}
bool on_seg(const point &p1, const point &p2, const point &q)
{
if (min(p1.x,p2.x) <= q.x && q.x <= max(p1.x,p2.y) &&
min(p1.y,p2.y) <= q.y && q.y <= max(p1.y,p2.y) && cross(p1,p2,p1,q) == 0) {
return true;
}
return false;
}
bool intersect(const point &p1, const point &p2, const point &q1, const point &q2)
{
if (cross(p1,q1,p1,p2)*cross(p1,p2,p1,q2) > 0 && cross(q1,p1,q1,q2)*cross(q1,q2,q1,p2) > 0)
return true;
return on_seg(p1,p2,q1) || on_seg(p1,p2,q2) || on_seg(q1,q2,p1) || on_seg(q1,q2,p2);
}
int get_cnt(int i, int n)
{
int temp(1);
for (int j(0); j<n; ++j) {
if (i == j)continue;
if (intersect(start,end,fir[j],sec[j]))++temp;
}
return temp;
}
void get_end(const point &p)
{
end.x = start.x + (p.x - start.x)*100000.0;
end.y = start.y + (p.y - start.y)*100000.0;
}
int main()
{
int t;
cin>>t;
while (t--) {
int n;
cin>>n;
for (int i(0); i<n; ++i) {
cin>>fir[i].x>>fir[i].y>>sec[i].x>>sec[i].y;
}
cin>>start.x>>start.y;
int cnt(1);
for (int i(0); i<n; ++i) {
get_end(fir[i]);
cnt = max(cnt,get_cnt(i,n));
get_end(sec[i]);
cnt = max(cnt,get_cnt(i,n));
}
cout<<cnt<<endl;
}
return 0;
}