交了兩天的半平面交的模版題終於過了,,,原來是 onleft 裡面少抄了乙個等於號......
半平面交 poj3335
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #includeview code10 #include 11 #include 12 #include 13 #include
14#define ll long long
15#define inf 0x3f3f3f3f
16#define eps 1e-10
17#define open_file
18using
namespace
std;
19int
n;20
21int dcmp(double
x)25
struct
point
31};
32struct
node
40};
41typedef point vector;
4243 vector operator +(vector a, vector b)
46 vector operator -(vector a, vector b)
49 vector operator * (vector a, double
p)52 vector operator / (vector a, double
p)55
bool
operator ==(vector a, vector b)
58bool
operator >(vector a, vector b)
61bool
operator
64//
點積65
double
dot(vector a, vector b)
68//模69
double
length(vector a)
72//
夾角73
double
angle(vector a, vector b)
76//
叉積77
double
cross(vector a, vector b)
80//
三角形面積
81double
area2(point a, point b, point c)
84struct
line
8590
line(point p, vector v) :p(p), v(v)
93bool
operator
< (const line & l) const
96};
97//
點p在直線l的左邊
98bool onleft(line l, point p)
99//
直線a,b的交點
100point getintersection(line a, line b)
101106
107int halfplaneintersection(line *l, int n, point *poly)
108125
if (first < last) p[last - 1] = getintersection(q[last - 1
], q[last]);
126}
127while (first < last && !onleft(q[first], p[last - 1])) last--;
128if (last - first <= 1) return0;
129 p[last] =getintersection(q[last], q[first]);
130int m = 0
;131
for (int i = first; i <= last; i++) poly[m++] =p[i];
132return
m;133
}134
135 line l[105
];136 point p[105], poly[105
];137 vector v[105
];138
intmain()
139154
for (int i = 0; i < n; i++)
157for (int i = 0; i < n; i++)
158161
if (halfplaneintersection(l, n, poly) != 0
)164
else
167}
168 }
凸包加旋轉卡殼 poj2187
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #includeview code10 #include 11 #include 12 #include 13 #include
14#define ll long long
15#define inf 0x3f3f3f3f
16#define open_file
17using
namespace
std;
1819
#define eps 1e-8
2021
struct
point
27};
28typedef point vector;
2930 vector operator +(vector a, vector b)
33 vector operator -(vector a, vector b)
36 vector operator * (vector a, int
p)39 vector operator / (vector a, int
p)42
bool
operator ==(vector a, vector b)
45bool
operator >(vector a, vector b)
48bool
operator
5152
intcross(vector a, vector b)
55int
distance(point a, point b)
58int convexhull(point *p, int n, point*ch)
65 ch[m++] =p[i];66}
67int k =m;
68for (int i = n - 2; i >= 0; i--)
72 ch[m++] =p[i];73}
74if (n > 1)77
return
m;78}79
int rotatecaliper(int m, point *ch)
88if (ch[j].x
92int res = 0, si = i, sj =j;
9394
while (i != sj || j !=si)
95100
else
103}
104return
res;
105}
106const
int maxn = 50005
;107
intn;
108point p[maxn], ch[maxn];
109int
main()
110119
int m =convexhull(p, n, ch);
120int ans =rotatecaliper(m, ch);
121 printf("
%d\n
", ans);
122}
123 }
暑假集訓總結
華信暑假集訓總結 暑假乙個月的總結 第一 就是不夠細心,關於這一點,在前兩次的總結都有提到,但是自己這次還是沒有改正過來,說明自己確實是粗心,不過在以後的學習過程中還是要克服這個問題!第二 自己寫的 結構很亂,模擬較多時,經常都會找不到自己在 定義的,這個又是在 寫的。所以在接下來的過程中,自己還是...
暑假集訓總結
暑假集訓這就結束了,這個暑假算是上學以來最充實的乙個暑假了,乙個暑假除了休息的兩個周之外,都在好好的學習,雖然每天從早坐到晚,一直在電腦面前冥思苦想,一遍遍的問自己 我到底錯在哪了 但還是有好多的收穫,學習到了知識,提高了自己寫 的能力,鍛鍊了思考問題的能力,而且還提前體驗一把碼農的感覺,近乙個月的...
暑假集訓總結
三十五天的集訓生活,伴隨著我們最後一次的個人賽的結束而結束了。這乙個多月的三點一線的生活,讓我再次感受到,為自己目標奮鬥的滿足感!1,集訓,讓我收穫的不僅僅是學習新的知識,還教會了我做人做事的大道理。從剛開始的分組賽到個人賽再到組隊賽,整個暑假集訓經歷了二十幾場比賽,很感激自己能一直遵守比賽規則到最...