跨立实验和相互排斥实验
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#define eps 0.01
#define pi 3.1415926
using namespace std;
struct point {
double x, y;
point() {};
point(double _x, double _y): x(_x), y(_y) {};
void sc() {
scanf("%lf%lf", &x, &y);
}
point operator -(point pt) {
return point(x - pt.x, y - pt.y);
}
double operator *(point pt) {
return x * pt.y - y * pt.x;
}
};
double k1, k2, k3, k4;
struct seg {
point p1;
point p2;
int judge(seg sg) {
point q1 = sg.p1;
point q2 = sg.p2;
if (min(p1.x, p2.x) <= max(q1.x, q2.x) &&
min(p1.y, p2.y) <= max(q1.y, q2.y) &&
min(q1.x, q2.x) <= max(p1.x, p2.x) &&
min(q1.y, q2.y) <= max(p1.y, p2.y)) {
k1 = (q1 - p1) * (p2 - p1);
k2 = (p2 - p1) * (q2 - p1);
k3 = (p2 - q1) * (q2 - q1);
k4 = (q2 - q1) * (p1 - q1);
if (k1 * k2 > 0 && k3 * k4 > 0)return 1;
return 0;
}
return 0;
}
} segs[2000];
int main() {
int n, i, j;
bool flag;
while (scanf("%d", &n) != EOF) {
flag = false;
for (i = 0; i < n; i++) {
segs[i].p1.sc();
segs[i].p2.sc();
if (!flag) {
for (j = 0; j < i; j++) {
if (segs[i].judge(segs[j])) {
flag = true;
break;
}
}
}
}
if(flag){
printf("burned!\n");
}else{
printf("ok!\n");
}
}
}