cf#Wunder Fund Round 2016 -C - Constellation-计算几何-水题
来源:互联网 发布:阿里云服务器图形界面 编辑:程序博客网 时间:2024/05/11 19:37
http://codeforces.com/contest/618/problem/C
给你n个点,保证 不会所有点在一条线上
让你找出一个三角形。使得三角形内部+边上没有任何别的点
直接按坐标排个序,for遍历连续的三个点作为三角形(必然不会有别的点在此三角形之内)
然后判断是否会面积为零,不会即合法,会则跳过
#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <iostream>#include <queue>#include <map>#include <set>#include <vector>#include<stack>using namespace std; const __int64 INF=9223372036854775807;struct POINT{int id;double x;double y;POINT(double a=0, double b=0) { x=a; y=b;}}; POINT tm[100000+5];double multiply(POINT sp,POINT ep,POINT op){return((sp.x-op.x)*(ep.y-op.y) - (ep.x-op.x)*(sp.y-op.y));} int cmp(POINT a,POINT b){if (a.x!=b.x)return a.x<b.x;else return a.y<b.y;} int main(){ int i,j;int n;cin>>n;for (i=1;i<=n;i++){scanf("%lf%lf",&tm[i].x,&tm[i].y); tm[i].id=i;}sort(tm+1,tm+1+n,cmp);int flag=0;for (i=1;i<=n-2;i++){ double cs=multiply(tm[i],tm[i+1],tm[i+2])/2;if (fabs(cs)<1e-6) continue; printf("%d %d %d\n",tm[i].id,tm[i+1].id,tm[i+2].id);break; } return 0;}
0 0
- cf#Wunder Fund Round 2016 -C - Constellation-计算几何-水题
- Wunder Fund Round 2016 C. Constellation(贪心+计算几何)
- Wunder Fund Round 2016 C. Constellation(贪心+计算几何)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) 618C Constellation(计算几何+stl)
- CF# Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C计算几何 + D 图论
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation(思维 简单几何)
- Codeforces Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)--C. Constellation
- Codeforces - Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)C - Constellation(数学练习)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-C. Constellation(贪心+向量平行判断)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-C. Constellation(贪心+向量平行判断)
- cf#Wunder Fund Round 2016 -A - Slime Combining-简单数学
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(C)几何
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) CF618C Constellation
- Codeforces Wunder Fund Round 2016 C D E
- Wunder Fund Round 2016 A. Slime Combining
- cf#Wunder Fund Round 2016 -B- Guess the Permutation-构造-乱搞
- Linux下卸载keepalived
- java8 stream.map和stream.forEach
- Java模拟post实现图片上传
- Kinect for Windows中文网站
- eclipse搭建erlang开发环境
- cf#Wunder Fund Round 2016 -C - Constellation-计算几何-水题
- 关于jquery中resize用法
- 对象管理器 3种方法实现 struct、 vector、map
- Android之SharedPreferences详解与原理分析
- 线程名字
- java8 list match
- Android 时间控件2.钟表
- 学堂在线--english list
- ADB server didn't ACK 问题解决办法汇总