【魔改】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 ...
随机推荐
- mvc4 强大的导出和不需要上传文件的批量导入EXCEL--SNF快速开发平台3.1
数据的导入导出,在很多系统里面都比较常见,这个导入导出的操作,在Winform里面比较容易实现,但在Web上我们应该如何实现呢?本文主要介绍利用MVC4+EasyUI的特点,并结合文件上传控件,实现文 ...
- pandas数组(pandas Series)-(5)apply方法自定义函数
有时候需要对 pandas Series 里的值进行一些操作,但是没有内置函数,这时候可以自己写一个函数,使用 pandas Series 的 apply 方法,可以对里面的每个值都调用这个函数,然后 ...
- linux每日命令(2):cd命令
1.命令格式: cd [目录名] 2.命令功能 切换当前目录至 [目录名] 3. 常用范例 1.进入系统根目录 命令: cd / 说明:进入系统根目录,上面命令执行完后拿ls命令看一下,当前目录已经到 ...
- sklearn linear_model,svm,tree,naive bayes,ensemble
sklearn linear_model,svm,tree,naive bayes,ensemble by iris dataset .caret, .dropup > .btn > .c ...
- java框架篇---hibernate主键生成策略
Hibernate主键生成策略 1.自动增长identity 适用于MySQL.DB2.MS SQL Server,采用数据库生成的主键,用于为long.short.int类型生成唯一标识 使用SQL ...
- InstallShield:卸载时文字叠加,文字乱码
问题: InstallShield2010打包的程序.如果程序正在运行,卸载程序,提示关闭程序,然后消息界面出现文字叠加. 定位问题: 新建Installshield项目,依次修改SetupType, ...
- 【Python】socket模块应用
[Socket] 本文记录了一些socket模块的简单应用,对于具体原理还没来得及深究. ■ 利用socket模块进行端口连接验证和扫描 在linux中常用nc命令来进行远端端口是否开放的验证.但是这 ...
- 【转】Spring Framework灰度发布
今天简单介绍下SpringFramework微服务中几种服务发布策略以及实现方式.我接触过的有蓝绿.滚筒和灰度发布. 蓝绿发布: 简单说就像美帝选总统投票一样,非蓝即绿一刀切,这个其实也是传统软件架构 ...
- Java如何从服务器获取文件大小?
在Java编程中,如何从服务器获取文件大小? 以下示例演示如何从服务器获取文件大小. package com.yiibai; import java.net.URL; import java.net. ...
- Dapper Extensions Change Schema
Dapper Extensions Change Schema You can use the AutoClassMapper to assign a new schema to your model ...