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设计, ...
随机推荐
- 腾讯云JavaWeb环境配置
腾讯云服务器Centos7系统配置javaWeb运行环境 java1.8 运行命令列表 yum list java-* 安装相应版本的jdk,一般含有devel的就是真正的jdk,如:java-1.8 ...
- 特殊符号 sort_wc_uniq命令 tee_tr_split命令
* 任意个 任意字符 ? 任意一个字符 # 注释字符 \ 转意符 | 管道符 (之前有说过) cut 命令: cut -d "&quo ...
- PTA——猜数字游戏
PTA 7-24 猜数字游戏 #include <stdio.h> int main() { int num, times; scanf("%d %d", &n ...
- Linux下安装Blender
Blender在Windows下,可以在官方直接下载免安装的版本,下载解压缩就能用. 在Linux下稍微麻烦一点点. 如下3步安装的blender不一定是最新版本,且安装完成后发现设置中文会变为方块. ...
- mvc core2.1 Identity.EntityFramework Core 登录 (三)
Controllers->AccountController.cs 新建 [HttpGet] [AllowAnonymous] public async Task<IActionResul ...
- CH5701 开车旅行
题意 5701 开车旅行 0x50「动态规划」例题 描述 小A和小B决定利用假期外出旅行,他们将想去的城市从1到N编号,且编号较小的城市在编号较大的城市的西边,已知各个城市的海拔高度互不相同,记城市 ...
- confluence 为合并的单元格新增一行
1,先将最后一个结构取消合并单元格 | | ___ | | | ___ | | _ | ___ | 2,在最后一行追加一行,将左侧合并 3,将上面取消合并的重新合并即可
- UWA 转载
性能优化,进无止境-内存篇 https://blog.uwa4d.com/archives/optimzation_memory_1.html https://blog.uwa4d.com/archi ...
- MySQL全文本搜索
启用全文本搜索支持 create table text( -> id int not null auto_increment, -> texts text null, -> prim ...
- Java Scanner学习记录
1. Java.util.Scanner可以用来从键盘获取输入 Scanner.next() 只能读取字符,遇到任何的符合都不会输出 Scanner.nextLine() 会完全按照用户输入的st ...