叉积判断 POJ1696
// 叉积判断 POJ1696 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
#define LL long long
typedef pair<int,int> pii;
const double inf = 123456789012345.0;
const int MOD = ;
const int N = 2e5+;
const int maxx = ;
#define clc(a,b) memset(a,b,sizeof(a))
const double eps = 1e-;
void fre() {freopen("in.txt","r",stdin);}
void freout() {freopen("out.txt","w",stdout);}
inline int read() {int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-; ch=getchar();}while(ch>=''&&ch<='') {x=x*+ch-'';ch=getchar();}return x*f;} int sgn(double x){
if(fabs(x) < eps)return ;
if(x < )return -;
else return ;
} struct Point{
double x,y;
int index;
Point(){}
Point(double _x,double _y){
x = _x;y = _y;
}
Point operator -(const Point &b)const{
return Point(x - b.x,y - b.y);
}
double operator ^(const Point &b)const{
return x*b.y - y*b.x;
}
double operator *(const Point &b)const{
return x*b.x + y*b.y;
}
}; double dist(Point a,Point b){
return sqrt((a-b)*(a-b));
} int pos;
Point p[];
bool cmp(Point a,Point b){
double tmp=(a-p[pos])^(b-p[pos]);
if(sgn(tmp)==){
return dist(a,p[pos])<dist(b,p[pos]);
}
else if(sgn(tmp)<) return false;
else return true;
} int main(){
int T,n;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%lf%lf",&p[i].index,&p[i].x,&p[i].y);
if(p[i].y<p[].y||(p[i].y==p[].y&&p[i].x<p[].x)){
swap(p[i],p[]);
}
}
pos=;
for(int i=;i<n;i++){
sort(p+i,p+n,cmp);
pos++;
}
printf("%d",n);
for(int i=;i<n;i++)
printf(" %d",p[i].index);
printf("\n");
}
return ;
}
叉积判断 POJ1696的更多相关文章
- TOYS - POJ 2318(计算几何,叉积判断)
题目大意:给你一个矩形的左上角和右下角的坐标,然后这个矩形有 N 个隔板分割成 N+1 个区域,下面有 M 组坐标,求出来每个区域包含的坐标数. 分析:做的第一道计算几何题目....使用叉积判断方 ...
- poj 2318(叉积判断点在线段的哪一侧)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13120 Accepted: 6334 Description ...
- POJ 2398 Toy Storage (叉积判断点和线段的关系)
题目链接 Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4104 Accepted: 2433 ...
- poj1556 The Doors(叉积判断线段相交)
题目链接:https://vjudge.net/problem/POJ-1556 题意:在一个矩形内,起点(0,5)和终点(10,5)是固定的,中间有n个道墙(n<=18),每道墙有两个門,求起 ...
- POJ2318TOYS(叉积判断点与直线位置)
题目链接 题意:一个矩形被分成了n + 1块,然后给出m个点,求每个点会落在哪一块中,输出每块的点的个数 就是判断 点与直线的位置,点在直线的逆时针方向叉积 < 0,点在直线的顺时针方向叉积 & ...
- POJ 2318 TOYS (计算几何,叉积判断)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8661 Accepted: 4114 Description ...
- POJ2318:TOYS(叉积判断点和线段的关系+二分)&&POJ2398Toy Storage
题目:http://poj.org/problem?id=2318 题意: 给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数.(其中这些线段 ...
- POJ 2398--Toy Storage(叉积判断,二分找点,点排序)
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6534 Accepted: 3905 Descr ...
- POJ 2318--TOYS(二分找点,叉积判断方向)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17974 Accepted: 8539 Description ...
随机推荐
- 创业草堂之十:换位思考:假如你是VC
前一回“创业草堂”的讲义是一份VC的Termsheet,这里面浓缩着VC投资关键性的理念. 今天来对Termsheet做些实质性的讲解.最有效的学习方法是创业者你亲自来扮演一回VC的角色,学习如何从V ...
- asp.net(C#)读取word 文档的方法
第一种方法 Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msw ...
- 关于spring-mvc的InitBinder注解的参数
关于spring-mvc的InitBinder注解的参数 通过Spring-mvc的@InitBinder注释的方法可以对WebDataBinder做一些初始化操作.比如设置Validator. 我一 ...
- IDEA快速光标跳转
Ace Jump是一种从emacs上借鉴过来的快速光标跳转方式,操作方式是:你用某个快捷键进入Ace Jump模式后,再按任一个键,当前屏幕中所有该字符都被打上一个字母标记,你只要按这个字母,光标就会 ...
- mapgis处理编辑属性结构时 死机问题
上午用的好好的mapgis6.7,下午就出错了,一编辑属性结构就出错,到网上查到了解决方法,和大家共享一下. 转自:http://bbs.3s001.com/forum.php?mod=viewthr ...
- Android Navigation Drawer,自定义ActionBar(标题居中)
整个示例都是改造自 Google Android Training 中的 NavigationDrawer 示例(http://developer.android.com/training/imple ...
- HTTP Basic Authorization
在HTTP中,Basic Authorization基本认证是一种用来允许Web浏览器或其他客户端程序在请求时提供用户名和口令形式的身份凭证的一种登录验证方式. 在发送之前是以用户名追加一个冒号然后串 ...
- 对Memcached使用的总结和使用场景
1.memcached是什么 Memcached 常被用来加速应用程序的处理,在这里,我们将着重于介绍将它部署于应用程序和环境中的最佳实践.这包括应该存储或不应存储哪些.如何处理数据的灵活分布以 及如 ...
- Windows XP搜索功能 "包含文字" 搜索不到内容的解决办法
Windows开始菜单 -- 运行 -- regedit -- 确定,编辑注册表 HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Control\ContentIndex 右 ...
- [UVA796]Critical Links(割边, 桥)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...