bzoj2856: [ceoi2012]Printed Circuit Board
Description

Input
Output
#include<bits/stdc++.h>
typedef long long i64;
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
const int N=;
char buf[],*ptr=buf;
int _(){
int x=;
while(*ptr<)++ptr;
while(*ptr>)x=x*+*ptr++-;
return x;
}
struct pos{
double x,y;
double val()const{return x+y;}
}xs[N];
double operator*(pos a,pos b){return a.x*b.y-a.y*b.x;}
pos operator-(pos a,pos b){return (pos){a.x-b.x,a.y-b.y};}
int n;
struct vertex{
pos p;
int id,x;
bool operator<(vertex w)const{
double d=p*w.p;
return d?d<:p.val()<w.p.val();
}
}vs[N];
int ps[N],xp=;
bool un[N];
struct itv{
pos a,b;
int l,r;
double operator()(pos&w)const{
return w.val()*(b*a)/(w*(a-b));
}
}is[];
int mx;
void ins(itv&a,itv&b){
if(!a.r)a=b;
else{
int l=max(a.l,b.l),r=min(a.r,b.r);
if(a(xs[l])+a(xs[r])>b(xs[l])+b(xs[r]))a=b;
}
}
void ins(vertex a,vertex b){
itv w=(itv){a.p,b.p,a.x,b.x};
for(int l=a.x+mx-,r=b.x+mx+;r-l!=;l>>=,r>>=){
if(~l&)ins(is[l^],w);
if(r&)ins(is[r^],w);
}
}
int as[N],ap=;
int main(){
fread(buf,,sizeof(buf),stdin);
n=_();
for(mx=;mx<=n+;mx<<=);
for(int i=;i<=n;++i){
vs[i].p.x=_();
vs[i].p.y=_();
vs[i].id=i;
}
std::sort(vs+,vs+n+);
for(int i=,j=;i<=n;i=j){
for(++j;j<=n&&vs[i].p*vs[j].p==;un[vs[j].id]=,++j);
xs[++xp]=vs[i].p;
for(int k=i;k<j;++k)vs[k].x=xp;
}
for(int i=;i<=n;++i)ps[vs[i].id]=i;
ps[]=ps[n];
for(int i=;i<=n;++i){
int a=ps[i-],b=ps[i];
if(a>b)std::swap(a,b);
if(vs[a].x<vs[b].x)ins(vs[a],vs[b]);
}
for(int i=;i<=n;++i)if(!un[vs[i].id]){
for(int w=vs[i].x+mx;w;w>>=)if(is[w].r&&is[w](vs[i].p)<vs[i].p.val()-1e-){
un[vs[i].id]=;
break;
}
}
for(int i=;i<=n;++i)if(!un[i])as[ap++]=i;
printf("%d\n",ap);
for(int i=;i<ap;++i)printf("%d ",as[i]);
return ;
}
bzoj2856: [ceoi2012]Printed Circuit Board的更多相关文章
- Printed Circuit Board (board)
Printed Circuit Board (board) 题目描述 给出一个N个顶点的简单多边形,对于每个顶点,假如它和原点连成的线段只在这个顶点处和多边形相交,就称为满足要求的顶点.你的任务是输出 ...
- ZOJ1648 Circuit Board 2017-04-18 20:31 34人阅读 评论(0) 收藏
Circuit Board Time Limit: 2 Seconds Memory Limit: 65536 KB On the circuit board, there are lots ...
- ZOJ 1648 Circuit Board(计算几何)
Circuit Board Time Limit: 2 Seconds Memory Limit: 65536 KB On the circuit board, there are lots of c ...
- ZOJ1648 Circuit Board(线段相交)
裸的判断线段相交
- kickstart2019 round_C B. Circuit Board
思路: 这题应该不止一种解法,其中的一种可以看作是leetcode85https://www.cnblogs.com/wangyiming/p/11059176.html的加强版: 首先对于每一行,分 ...
- zoj 1648 Circuit Board
题目:意思就是推断给定的几条线段是否有相交的. 方法:模版吧,有空在来细细学习. 代码: #include <iostream> #include <cstdio> using ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- COB(Chip On Board) 工艺技术
COX(Chip On X) •X 基板: PCB (Printed circuit board) FPC (Flexible Printed Circuit) Glass •导线焊接 球形焊接 ...
- 特邀美国EMC实战专家Mark来华授课
“轻松搞定EMC-PCB和系统设计”课程介绍 本次课程特邀美国EMC领域权威专家Mark Montrose主讲,将涵盖满足产品电磁兼容性和信号完整性的基本原理.课程涉及多个领域,不仅仅针对PCB设计, ...
随机推荐
- 测试那些事儿—BUG
一.作为测试人员,你应该这样报BUG: 不要对程序员说,你的代码有BUG. 他的第一反应是:1.你的环境有问题吧:2.你踏马到底会不会用? 如果你委婉的说:你这个程序和预期的不一样,你看看是不是我的方 ...
- python 闭包和迭代器
一 函数名的运用:(函数名是一个变量,但它是一个特殊变量,与括号配合可以执行变量. (1) 函数名可以赋值给其他变量 def chi(): print("吃月饼") fn=chi ...
- CodeForces 4A
A A - Water~melon Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit St ...
- C++学习(十四)(C语言部分)之 数组
上期回顾:三大循环 for while do while (循环体至少会执行一次)四大跳转 goto continue(提前跳出当前循环 进入下一个循环) break(跳出本次循环) return(跳 ...
- Python中msgpack库的使用
msgpack用起来像json,但是却比json快,并且序列化以后的数据长度更小,言外之意,使用msgpack不仅序列化和反序列化的速度快,数据传输量也比json格式小,msgpack同样支持多种语言 ...
- (惊艳)基于谷底最小值的阈值的图像分割(改进HSV中的H分量可以用imhist(H)提取)
任务概述:将这张图片作为输入 , 然后抠出只有斑点的图片 灵感来源: 1. 黄色部分用绿色的掩盖掉得到图片B,然后A和B进行∩运算,相同的设置为0 2.统计单词的子母数,开辟一个26个元素的数组,进来 ...
- Server 2008 R2部署active directory服务器-ad域
一.部署AD域: 系统环境:Windows server 2008 R2 标准版 ip:172.16.1.149服务器开机后会自动弹出一个初始配置任务窗口(这个不要随便关闭,因为我不知道关闭后能在哪里 ...
- photoshop 笔记
替换颜色 (图像)—(调整)—(替换颜色)—点下你想换掉的绿色----拖动下方的滑 块—(色相)拖到最大—(饱合度)调到最小----(明度)调到最大 OK 发现对你不想变色的图像稍微有点影响,但只是一 ...
- Creating Node.js Command Line Utilities to Improve Your Workflow
转自:https://developer.telerik.com/featured/creating-node-js-command-line-utilities-improve-workflow/ ...
- 填充整个区间(fill,fill_n,generate和generate_n)
fill 将value值填充整个区间,不能为OutputIterator,因为fill会用到first和last,outputIterator无法做相等的测试 template <class F ...