題目大意:
給定n條線段,按輸入依次編號為1-n,求哪些線段不與任何編號大於這條線段相交,並輸出它們的編號。
這道題就是套乙個計算幾何模板,然後每條線段判斷是否與之後的線段相交,然後輸出就可以了。
**如下:
#include
#include
#include
#include
#include
using
namespace
std;
class point
};typedef point vector;
vector operator + (const vector &a, const vector &b)
vector operator - (const point &a, const point &b)
vector operator * (const vector &a, const
double &b)
vector operator / (const vector &a, const
double &b)
double cross(const vector &a, const vector &b)
double dot(const vector &a, const vector &b)
point lineintersection(point p, vector v, point q, vector w)
bool online(point a, point b, point p)
point p[100050];
point q[100050];
vector v[100050];
bool ans[100050];
bool check(point p, vector v, point q, vector w)
int main()
for (int i = 1; i < n; i++)
}printf("top sticks:");
for (int i = 1; i < n; i++)
if (ans[i])
printf(" %d,", i);
printf(" %d.\n", n);
}return
0;}
POJ 2653 計算幾何 判斷線段相交
題意 按順序給出一些木棍,輸出在最上面的木棍標號 題解 一開始看到n 100000還在想怎麼優化,沒想出來,最後看討論,原來暴力可以水過 嘿嘿 用了下並查集壓縮路徑,在刷陣列的時候會快一些 view code 1 include 2 include 3 include 4 include 5 inc...
poj1696 計算幾何
運用叉積判斷是否是逆時針,因為同一直線上也行,所以有n個植物就可以吃掉n個植物 include include include include include define dist a,b sqrt 1.0 a.x b.x a.x b.x 1.0 a.y b.y a.y b.y define cr...
poj1106 計算幾何
求在可以旋轉的給定圓心和半徑的半圓中最多點的個數 include include include include include define dist a,b sqrt 1.0 a.x b.x a.x b.x 1.0 a.y b.y a.y b.y define cross a,b,c 1.0 b...