[几何] Codeforces 772B VK Cup 2017 - Round 2 B. Volatile Kite
2017-06-13 22:39
302 查看
那么问题来了 O(n)判到底对不对
#include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; typedef double ld; struct P{ ld x,y; void read() { double _x,_y; scanf("%lf%lf",&_x,&_y); x=_x; y=_y; } P(ld x=0,ld y=0):x(x),y(y) { } P rot(ld A){ return P(x*cos(A)-y*sin(A),x*sin(A)+y*cos(A)); } ld dist(){ return sqrt(x*x+y*y); } friend P operator + (P A,P B) { return P(A.x+B.x,A.y+B.y); } friend P operator - (P A,P B) { return P(A.x-B.x,A.y-B.y); } friend ld operator * (P A,P B) { return A.x*B.y-B.x*A.y; } friend P operator * (P A,ld B) { return P(A.x*B,A.y*B); } friend P operator / (P A,ld B) { return P(A.x/B,A.y/B); } friend ld dist(P A,P B){ return (A-B).dist(); } }p[1005]; int n; inline ld solve(P A,P B,P C){ return fabs((A-C)*(B-C))/((B-A).dist()); } int main(){ freopen("t.in","r",stdin); freopen("t.out","w",stdout); scanf("%d",&n); for (int i=0;i<n;i++) p[i].read(); ld ans=1e15; for (int i=0;i<n;i++) ans=min(ans,solve(p[(i+n-1)%n],p[(i+1)%n],p[i])); printf("%.10lf\n",ans/2); return 0; }
相关文章推荐
- [交互 点分治] Codeforces 772E VK Cup 2017 - Round 2 E. Verifying Kingdom
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D. Volatile Kite
- Codeforces-Good Bye 2017 C. New Year and Curling(计算几何)
- [最短路 杂题] Codeforces 806D VK Cup 2017 Round 3 D. Perishable Roads
- [线段树 杂题] Codeforces 806E VK Cup 2017 Round 3 E. Blog Post Rating
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D (简单计算几何)
- VK Cup 2017 B. Volatile Kite (Div . 1)(凸多边形退化)(计算几何)
- Codeforces 8VC Venture Cup 2017 - Elimination Round D.PolandBall and Polygon
- [数论 DAG最长路] Codeforces 772C VK Cup 2017 - Round 2 C. Vulnerable Kerbals
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D. Volatile Kite
- [杂题] Codeforces 772D VK Cup 2017 - Round 2 D. Varying Kibibits
- Google Kickstart 2017 Round A 题解
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 – Elimination Round 2) A. Interview wi
- Kickstart Round D 2017 : A
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
- 【Codeforces Round 330 (Div 2)D】【计算几何 二分答案】Max and Bike 最小骑车距离使得圆上传感器很坐标位移为dis
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C
- 【树形dp】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) B. Bear and Tree Jumps