【魔改】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 ...
随机推荐
- pureftpd.passwd解析
将pureftpd.passwd文件的内容转换成sql语句,导入到mysql pureftp.passwd格式: <account>:<password>:<uid> ...
- nodeJs--模块module.exports与实例化方法
在nodejs中,提供了exports 和 require 两个对象,其中 exports 是模块公开的接口,require 用于从外部获取一个模块的接口,即所获取模块的 exports 对象.而在e ...
- Atitit mybatis快速开发 的sql api接口
Atitit mybatis快速开发 的sql api接口 1.1. sql模式 开发速度大大快与 映射模式1 1.2. MyBatis Mapper1 1.2.1. 代码2 1.2.2. 原理2 1 ...
- [转]PowerDesigner大小写转换
原文地址:https://blog.csdn.net/fzqlife/article/details/72769959?utm_source=blogxgwz7 在菜单栏找到:Tools-->E ...
- 【iCore4 双核心板_FPGA】例程十:FSMC总线通信实验——复用地址模式
实验原理: STM32F767上自带FMC控制器,本实验将通过FMC总线的地址复用模式实现STM32与FPGA 之间通信,FPGA内部建立RAM块,FPGA桥接STM32和RAM块,本实验通过FSMC ...
- Java编程的逻辑 (83) - 并发总结
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http: ...
- android开发(49) Android 下拉刷新的实现。使用 SwipeRefreshLayout 代替 pull-to-refesh
概述 谷歌官方推出了SwipeRefreshLayout 来实现下拉刷新的效果.对比以前我们常用的 pull-to-refesh ,这个方案显得更加的简单方便. 关联项目引用(管理依赖) 在你的 应用 ...
- vue事件处理器
1.监听事件 可以用 v-on 指令监听 DOM 事件来触发一些 JavaScript 代码. 示例: <div id="example-1"> <button ...
- Cocos2d-x 3.0 纹理
1.纹理控制. Sprite *pSprite = Sprite::create("background.png"); TexParams params = {GL_NEAREST ...
- Go指南练习_循环与函数
源地址 https://tour.go-zh.org/flowcontrol/8 一.练习题描述 为了练习函数与循环,我们来实现一个平方根函数:用牛顿法实现平方根函数. 计算机通常使用循环来计算 x ...