Printed Circuit Board (board)

 Printed Circuit Board (board)

题目描述

 

给出一个N个顶点的简单多边形,对于每个顶点,假如它和原点连成的线段只在这个顶点处和多边形相交,就称为满足要求的顶点。你的任务是输出所有满足要求的顶点编号。

 

 

 

输入

 

第一行一个正整数N。下面N行每行两个不超过10e6的正整数,依次表示每个顶点的坐标。顶点按照输入顺序用正整数1..N编号,并且顶点保证按照顺时针或逆时针顺序给出。

 

 

输出

 

第一行一个正整数M,表示满足要求的顶点个数。第二行M个正整数,按照升序给出满足要求的顶点编号。


solution

计算几何好题

首先我们按极角把点离散化了。

一条条加入边,判断覆盖一个点的边是不是他的临边就是答案

注意到覆盖区间时没必要覆盖到底,打在区间上即可,查询时一路统计答案。

那么·还剩一个问题,怎么判断两条边谁前谁后。

我们用

第一条边y较小的和第二条边y较大的

第一条边y较大的和第二条边y较小的

叉积起来

画画图就可以发现了

有一个细节,相同斜率的点其实不用特判。

因为那些点怎么都不会被覆盖。

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define db double
#define ll long long
#define maxn 200005
#define inf 1e9
using namespace std;
int n,tot,li,ri,ans[maxn],flag[maxn],t;
struct node{
    int x,y,id;db k;
}s[maxn];
int tr[maxn*4];
map<double,int>l;
bool cmp(node a,node b){
     
    return a.k<b.k||(a.k==b.k&&a.x<b.x);
}
bool C(node a,node b){
    return a.id<b.id;
}
node xl(node a,node b){
    node t;t.x=b.x-a.x;t.y=b.y-a.y;return t;
}
ll cr(node a,node b){
    return (ll)a.x*b.y-(ll)a.y*b.x;
}
bool pd(int a,int b){
    node p1,p2,p3,p4;
    p1=s[a];p2=s[a+1];if(a==n)p2=s[1];
    p3=s[b];p4=s[b+1];if(b==n)p4=s[1];
    if(p1.k>p2.k)swap(p1,p2);if(p3.k>p4.k)swap(p3,p4);
    node A=xl(p1,p4),B=xl(p2,p3);
    if(cr(A,B)<0)return 0;//a close 
    else return 1;
}
void update(int &x,int now){
    if(!x)x=now;
    else if(pd(x,now))x=now;
}
void add(int k,int l,int r,int id){
    if(l>=li&&r<=ri){update(tr[k],id);return;}
    int mid=l+r>>1;
    if(li<=mid)add(k*2,l,mid,id);
    if(ri>mid)add(k*2+1,mid+1,r,id);
}
void ask(int k,int l,int r,int pl){
    if(tr[k])update(t,tr[k]);
    if(l==r)return;
    int mid=l+r>>1;
    if(pl<=mid)ask(k*2,l,mid,pl);
    else ask(k*2+1,mid+1,r,pl);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&s[i].x,&s[i].y);s[i].id=i;
        if(!s[i].x)s[i].k=inf;
        else s[i].k=(db)s[i].y/(db)s[i].x;
    }
    sort(s+1,s+n+1,cmp);
    s[0].k=-1;
    for(int i=1;i<=n;i++){
        if(s[i].k==s[i-1].k){flag[s[i].id]=1;continue;}
        l[s[i].k]=++tot;
    }
    sort(s+1,s+n+1,C);
    for(int i=1;i<=n;i++){
        li=l[s[i].k],ri=l[s[i+1].k];int D=i;
        if(i==n)ri=l[s[1].k];
        if(li>ri)swap(li,ri);
        add(1,1,n,i);
    }
    for(int i=1;i<=n;i++){
        t=0;ask(1,1,n,l[s[i].k]);
        if(i==1){if(t==n||t==1)ans[i]=1;}
        else {if(t==i||t==i-1)ans[i]=1;}
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(flag[i])continue;
        if(ans[i])sum++;
    }
    cout<<sum<<endl;
    for(int i=1;i<=n;i++){
        if(flag[i])continue;
        if(ans[i])printf("%d ",i);
    }
    cout<<endl;
    return 0;
}
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Preface Printed Circuit Board Design Techniques for EMC Compliance: A Handbook for Designers, Second Edition, is a significant enhancement to the first edition. The first edition was well received within the engineering community worldwide and was translated into international languages. The intent of the present volume is to expand upon concepts presented in the earlier edition, to justify why a specific design technique works, and to show when it is appropriate for use. Additional techniques based on technological changes within the last few years are also incorporated. These techniques and enhancements are based on questions, comments, and discussions received from engineers around the world. This book presents information never before published within the engineering community, dealing exclusively with printed circuit boards (PCBs). When writing the first edition, it was impossible to anticipate the amount of variations possible, or what the intended audience expected from a book directed toward nondegreed engineers. A thorough understanding of the concepts presented herein will assist during the design and layout process. Note the key word here —"concepts." Printed Circuit Board Design Techniques for EMC Compliance will help minimize the emission or reception of unwanted radio frequency (RF) energy generated by components and circuits, thus achieving acceptable levels of electromagnetic compatibility (EMC) for electrical equipment. The field of EMC consists of two distinct areas: 1. Emissions: Propagation of electromagnetic interference (EMI) from noncompliant devices (culprits) and, in particular, radiated and conducted electromagnetic interference. 2. Susceptibility or immunity: The detrimental effects on susceptible devices (victims) in forms that include EMI, electrostatic discharge (ESD), and electrical overstress (EOS). The primary goal of the engineer is to ensure proper operation and performance of a product when used within an intended electromagnetic environment. These design requirements are in addition to making a product function as desired for use within a specific, end-use environment. Information presented in this guideline is intended for those who design and layout printed circuit boards. EMC and compliance engineers will also find the information presented herein helpful in solving design problems at both the PCB and system level. This book can be used as a reference document for any design project. The focus of this book is strictly on the PCB. Containment techniques (shielding), internal and external cabling, power supply design, and other system-level subassemblies that use PCBs as a subcomponent will not be discussed. Again, as in the first edition, excellent reference material on these aspects of EMC system-level engineering is listed in the References section at the ends of chapters.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值