// 叉积判断 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的更多相关文章

  1. TOYS - POJ 2318(计算几何,叉积判断)

    题目大意:给你一个矩形的左上角和右下角的坐标,然后这个矩形有 N 个隔板分割成 N+1 个区域,下面有 M 组坐标,求出来每个区域包含的坐标数.   分析:做的第一道计算几何题目....使用叉积判断方 ...

  2. poj 2318(叉积判断点在线段的哪一侧)

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13120   Accepted: 6334 Description ...

  3. POJ 2398 Toy Storage (叉积判断点和线段的关系)

    题目链接 Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4104   Accepted: 2433 ...

  4. poj1556 The Doors(叉积判断线段相交)

    题目链接:https://vjudge.net/problem/POJ-1556 题意:在一个矩形内,起点(0,5)和终点(10,5)是固定的,中间有n个道墙(n<=18),每道墙有两个門,求起 ...

  5. POJ2318TOYS(叉积判断点与直线位置)

    题目链接 题意:一个矩形被分成了n + 1块,然后给出m个点,求每个点会落在哪一块中,输出每块的点的个数 就是判断 点与直线的位置,点在直线的逆时针方向叉积 < 0,点在直线的顺时针方向叉积 & ...

  6. POJ 2318 TOYS (计算几何,叉积判断)

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8661   Accepted: 4114 Description ...

  7. POJ2318:TOYS(叉积判断点和线段的关系+二分)&&POJ2398Toy Storage

    题目:http://poj.org/problem?id=2318 题意: 给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数.(其中这些线段 ...

  8. POJ 2398--Toy Storage(叉积判断,二分找点,点排序)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6534   Accepted: 3905 Descr ...

  9. POJ 2318--TOYS(二分找点,叉积判断方向)

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17974   Accepted: 8539 Description ...

随机推荐

  1. Unix编程之size_t、ssize_t

    http://blog.csdn.net/lalor/article/details/7426184 首先,我非常肯定以 及确定的告诉你ssize_t是有符号整型,在32位机器上等同与int,在64位 ...

  2. 使用MyBatis链接MySQL

    本文主要介绍了如何使用mybatis进行简单的数据库操作.本人使用的是mybatis3.05. 1.创建数据库表(User表) CREATE TABLE `NewTable` (`userId` bi ...

  3. Photoshop:笔刷制作和安装

    笔刷制作 1.新建一个文档,大小为要制作的笔刷大小,把画笔图像放里面 2.选择:菜单->编辑->定义画笔预设,这时在画笔面板中会出现刚定义的画笔 3.存储画笔,可以把当前的笔刷保存为一个. ...

  4. 89. Gray Code

    题目: The gray code is a binary numeral system where two successive values differ in only one bit. Giv ...

  5. 用git difff 生成补丁

    http://stackoverflow.com/questions/1191282/how-to-see-the-changes-between-two-commits-without-commit ...

  6. oracle portlist.ini

    Enterprise Manager Database Control URL - (orcl) :https://redhat4.7:1158/em [root@redhat4 install]# ...

  7. Android Touch事件分发机制

    参考:http://blog.csdn.net/xiaanming/article/details/21696315 参考:http://blog.csdn.net/wangjinyu501/arti ...

  8. Java 日期时间

    Java 日期时间 标签 : Java基础 Date java.util.Date对象表示一个精确到毫秒的瞬间; 但由于Date从JDK1.0起就开始存在了,历史悠久,而且功能强大(既包含日期,也包含 ...

  9. springMVC传对象参数、返回JSON格式数据

    假如请求路径:http://localhost/test/test.do?user.id=1 后台接收参数的方法如下: @RequestMapping("/test") publi ...

  10. Entity Framework查询,EF执行SQl

    一.简介 EF 支持开放底层的 ADO.NET 框架,DbContext有三种常用方法 DbSet.SqlQuery //查询并返回Entities DbContext.Database.SqlQue ...