【魔改】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 ...
随机推荐
- Effective Java 第三版——52. 明智而审慎地使用重载
Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...
- 并发和多线程-八面玲珑的synchronized
上篇<并发和多线程-说说面试常考平时少用的volatile>主要介绍的是volatile的可见性.原子性等特性,同时也通过一些实例简单与synchronized做了对比. 相比较volat ...
- latex学习(三)
本文记录一点杂事. 1.vim下有个实时pdf预览的插件:https://github.com/xuhdev/vim-latex-live-preview 2.实时预览pdf的pdf查看器是:evin ...
- 译:4.RabbitMQ Java Client 之 Routing(路由)
在上篇博文 译:3.RabbitMQ 之Publish/Subscribe(发布和订阅) 我们构建了一个简单的日志系统 我们能够向许多接收者广播日志消息. 在本篇博文中,我们将为其添加一个功能 - ...
- 国外程序员整理的C++资源大全
标准库 C++标准库,包括了STL容器,算法和函数等. C++ Standard Library:是一系列类和函数的集合,使用核心语言编写,也是C++ISO自身标准的一部分. Standard Tem ...
- IOS开发之Storyboard应用
制作一个Tab类型的应用 制作一个表格视图 原型表格单元 设计自定义的原型单元格 为原型单元格设置子类 故事版(Storyboard)是一个能够节省你很多设计手机App界面时间的新特性,下面,为了简明 ...
- MXNET:监督学习
线性回归 给定一个数据点集合 X 和对应的目标值 y,线性模型的目标就是找到一条使用向量 w 和位移 b 描述的线,来尽可能地近似每个样本X[i] 和 y[i]. 数学公式表示为\(\hat{y}=X ...
- JS原生实现视频弹幕Demo(仿)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- Brainfuck解析器(Python)
global cs global ip global ss #global sp global ds global bp global tab global out cs='++++++++++[&g ...
- (原)android系统下绑定Server的时候报MainActivity has leaked ServiceConnection的错误
今天在android系统下根据官方的demo代码,我们需要启动一个服务,并绑定,但在程序启动以后,老是报错: Activity MainActivity has leaked ServiceCon ...