【魔改】hdu6325 多校赛3G xy排序凸包+llvector模板
凸包算法前的预处理,可以极角排序,也可以按X,Y轴排序,
极角排序需要找到角落里的一个点,Xy轴排序要跑两遍凸包
而本题的要求只要一个上半凸包,并且有X轴从小到大以及字典序限制,完全符合xy排序,直接一个循环就过了
坑点:我输出了整个数组的大小,然后完全无视了,wa了12发orz
学会了cmd 的fc来比较文件,多校赛数据都是20M的orz
#define _CRT_SECURE_NO_WARNINGS
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<vector>
#include<string.h>
#include<queue>
#include<string>
#include<set>
#include<time.h>
using namespace std;
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define eps 1e-6
#define pb push_back
const int maxn = 2e5 + ;
const int inf = 1e7 + ;//0x7fffffff; //无限大
const int MOD = ;
typedef long long ll; struct V {
ll x, y;
int rk;
//V() {}
void sc() { scanf("%lld%lld", &x, &y); }
V(ll a=, ll b=,int rk=) : x(a), y(b),rk(rk) { }
V operator+(V o) { return V(x + o.x, y + o.y); }
V operator-(V o) { return V(x - o.x, y - o.y); }
double L() { return sqrt(x * x + y * y); }
V N() {
double l = L();
return V(x / l, y / l);
}
V rot(double th) { return V(x * cos(th) - y * sin(th), x * sin(th) + y * cos(th)); }
V operator*(ll z) { return V(x * z, y * z); }
ll operator*(V o) { return x * o.x + y * o.y; }
ll operator|(V o) { return 1ll*x * o.y - 1ll*o.x * y; }
bool operator ==(V o) { return x == o.x&&y == o.y; }
void pr() { printf("%lld %lld\n", x, y); }
} p[maxn], P[maxn]; int n, top, head; bool cmp(V A, V B)
{
if (A.x != B.x)return A.x < B.x;
if (A.y != B.y)return A.y > B.y;
return A.rk < B.rk;
} void smain() {
int t; cin >> t;
while (t--) { cin >> n;
rep(i, , n)
{ p[i].sc(); p[i].rk = i; }
top = ;
sort(p + , p + + n, cmp);
P[] = p[], P[] = p[];
top = ;
rep(i, , n) {
if (p[i] == P[top])continue;
while ( top > &&( (((p[i] - P[top]) | (P[top - ] - P[top])) > )||(((p[i] - P[top]) | (P[top - ] - P[top]))== &&P[top].rk>p[i].rk)) )top--;
P[++top] = p[i]; }
rep(i, , top) {
i!=top?printf("%d ", P[i].rk): printf("%d\n", P[i].rk);
} }
cin >> n; }
#define ONLINE_JUDGE
int main() {
//ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
FILE *myfile;
myfile = freopen("C:\\Users\\acm-14\\Desktop\\test\\G.in", "r", stdin);
if (myfile == NULL)
fprintf(stdout, "error on input freopen\n");
FILE *outfile;
outfile= freopen("C:\\Users\\acm-14\\Desktop\\test\\out.txt", "w", stdout);
if (outfile == NULL)
fprintf(stdout, "error on output freopen\n");
long _begin_time = clock();
#endif
smain();
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %ld ms.", _end_time - _begin_time);
#endif
return ;
}
/*
2
3
0 0
1 0
2 0
4
0 0
3 0
2 0
5 0 5
0 0
1 3
2 1
4 4
5 0 //1 2 4 5
*/
【魔改】hdu6325 多校赛3G xy排序凸包+llvector模板的更多相关文章
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- 2014上半年acm总结(1)(入门+校赛)
大一下学期才开始了acm,不得不说有一点迟,但是acm确实使我的生活充实了很多,,不至于像以前一样经常没事干= = 上学期的颓废使我的c语言学的渣的一笔..靠考前突击才基本掌握了语法 寒假突然醒悟, ...
- 【题解】LOJ2462完美的集合(树DP 魔改Lucas)
[题解]LOJ2462完美的集合(树DP 魔改Lucas) 省选模拟考这个??????????????????? 题目大意: 有一棵树,每个点有两个属性,一个是重量\(w_i\)一个是价值\(v_i\ ...
- 魔改——MDI多视图模板Tab/标签页 初始化/操作控件
==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...
- 魔改——MFC SDI程序 转换为 MDI程序
==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...
- 魔改——MFC MDI程序 定制 文档模板 运行时全部打开 禁用关闭按钮
==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...
- SCNU省选校赛第二场B题题解
今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...
- 2017CUIT校赛-线上赛
2017Pwnhub杯-CUIT校赛 这是CUIT第十三届校赛啦,也是我参加的第一次校赛. 在被虐到崩溃的过程中也学到了一些东西. 这次比赛是从5.27早上十点打到5.28晚上十点,共36小时,中间睡 ...
- HZNU第十二届校赛赛后补题
愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...
随机推荐
- 12C -- 配置Application Continuity
- system函数遇到的问题
这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同的system()函数,直接在shell下输入system()函数中调用的命令也都一切正常.就没理这个bug,以 ...
- 视音频数据处理入门:AAC音频码流解析
===================================================== 视音频数据处理入门系列文章: 视音频数据处理入门:RGB.YUV像素数据处理 视音频数据处理 ...
- asp.net C# int 类型在32/64位环境下取值范围无变化
最近在学习中突然想到,我在64位环境下,int取值范围是否有变化?为了检测这个结果,我做了以下这个测试:1.环境:win7旗舰版64位+vs2010 sp1(版本号:10.0.40219.1SP1Re ...
- SNF快速开发平台WinForm-CS甘特图
我们在做项目当中会经常用到按时间进度查看任务,其通过条状图来显示项目,进度,和其他时间相关的系统进展的内在关系随着时间进展的情况. 甘特图包含以下三个含义: 1.以图形或表格的形式显示活动: 2.通用 ...
- css min-width和max-width
min-width: 浏览器缩小设置min-width,元素最小也是min-width设置的值.设置min-width元素不会压扁. max-width:元素最大宽度
- 1. Tensorflow高效流水线Pipeline
1. Tensorflow高效流水线Pipeline 2. Tensorflow的数据处理中的Dataset和Iterator 3. Tensorflow生成TFRecord 4. Tensorflo ...
- elasticsearch和mysql排序问题
elasticsearch 字段类型错误 最近用elasticseach做排序,排序字段是float型的,没有使用mapping,是直接写代码导入的,没想到排序时如果有小数和整数就会出现错误. 于是查 ...
- Android——Android和SVN::::SVN+delete项目
SVN使用笔记(比较详细) http://www.cnblogs.com/merray/p/4182380.html 删除项目 http://jingyan.baidu.com/article/c74 ...
- 错误:OSError: [Errno 1] Operation not permitted: 'lib/python/six-1.4.1-py2.7.egg-info'
解决办法: $ $ pip install mock --ignore-installed six --user 问题:安装mock时报错: (venv)➜ test git:(master) pip ...