zoukankan      html  css  js  c++  java
  • [bzoj4140] 共点圆加强版

      就是2961的强制在线版...

      那就二进制分组了..不过我没有每次重新建,而是直接把两组的凸包合并起来..这样修改部分就只有一个log了。。。不过每次询问还是要两个log的

      空间有点卡。。

      1 #include<cstdio>
      2 #include<iostream>
      3 #include<cstring>
      4 #include<algorithm>
      5 #include<cmath>
      6 #include<cstdlib>
      7 #include<queue>
      8 #define ll long long
      9 #define ui unsigned int
     10 #define d double
     11 using namespace std;
     12 const int maxn=500023;const d eps=1e-7;
     13 struct zsp{d x,y;}p[maxn];int np;
     14 struct zstb{int l,r;}stb[maxn],xtb[maxn];int _num;
     15 int st[maxn],TOP,prest[maxn];d tbk[maxn];
     16 int _st[maxn],_sz[maxn],_top;
     17 int i,j,k,n,m; d NX,NY;
     18  
     19   
     20 int ra,fh;char rx;
     21 inline int read(){
     22     rx=getchar(),ra=0,fh=1;
     23     while(rx!='-'&&(rx<'0'||rx>'9'))rx=getchar();
     24     if(rx=='-')fh=-1,rx=getchar();
     25     while(rx>='0'&&rx<='9')ra=ra*10+rx-48,rx=getchar();return ra*fh;
     26 }
     27  
     28 inline d max(d a,d b){return a>b?a:b;}
     29 inline d min(d a,d b){return a<b?a:b;}
     30 inline d getk(int a,int b){return (p[b].y-p[a].y)/(p[b].x-p[a].x);}
     31 inline bool istb(int a,int b,int c,bool isstb){
     32     if(isstb)return (p[c].x-p[b].x)*(p[b].y-p[a].y) > (p[b].x-p[a].x)*(p[c].y-p[b].y);
     33     else return (p[b].x-p[a].x)*(p[c].y-p[b].y) > (p[c].x-p[b].x)*(p[b].y-p[a].y);
     34 }
     35  
     36 inline bool check(int a/*,int b*/){//µãbÔÚÔ²aÄÚ
     37 //  printf("  check:%d
    ",a);
     38     return p[a].x*p[a].x+p[a].y*p[a].y +eps > (p[a].x-NX)*(p[a].x-NX)+(p[a].y-NY)*(p[a].y-NY);
     39 }
     40  
     41  
     42 inline void mergetb(int x,int y){
     43     int i,l1=stb[x].l,l2=stb[y].l,r1=stb[x].r,r2=stb[y].r,sz=r1-l1+1+r2-l2+1,now;
     44     _sz[x]+=_sz[y];
     45     memcpy(prest+l1,st+l1,(_sz[x]*2)<<2);
     46 //  printf("buildtb:");for(i=l;i<=r;i++)if(!p[dl[i]].ask)printf("    (%.2lf,%.2lf)",p[dl[i]].x,p[dl[i]].y);puts("");
     47      
     48     TOP=l1-1,stb[x].l=TOP+1;
     49     for(i=sz;i;i--){
     50         now=((l2>r2)||(l1<=r1&&p[prest[l1]].x<=p[prest[l2]].x))?prest[l1++]:prest[l2++];
     51         if(TOP>=stb[x].l&&p[st[TOP]].x==p[now].x)
     52             if(p[now].y>p[st[TOP]].y)TOP--;else continue;
     53         while(TOP>stb[x].l&&!istb(st[TOP-1],st[TOP],now,1))TOP--;
     54         st[++TOP]=now;
     55     }stb[x].r=TOP;
     56     for(i=stb[x].l;i<TOP;i++)tbk[i]=getk(st[i],st[i+1]);
     57      
     58     l1=xtb[x].l,l2=xtb[y].l,r1=xtb[x].r,r2=xtb[y].r,sz=r1-l1+1+r2-l2+1;
     59     xtb[x].l=TOP+1;
     60     for(i=sz;i;i--){
     61         now=((l2>r2)||(l1<=r1&&p[prest[l1]].x<=p[prest[l2]].x))?prest[l1++]:prest[l2++];
     62         if(TOP>=xtb[x].l&&p[st[TOP]].x==p[now].x)
     63             if(p[now].y<p[st[TOP]].y)TOP--;else continue;
     64         while(TOP>xtb[x].l&&!istb(st[TOP-1],st[TOP],now,0))TOP--;
     65         st[++TOP]=now;
     66     }xtb[x].r=TOP;
     67     for(i=xtb[x].l;i<TOP;i++)tbk[i]=getk(st[i],st[i+1]);
     68 }
     69  
     70 inline bool _check(int id){
     71     d nk=-NX/NY;int l,r,mid;
     72     if(NY<0){
     73         l=stb[id].l,r=stb[id].r-1;
     74         if(l>r||nk>=tbk[l])return check(st[l]);
     75         if(nk<=tbk[r])return check(st[r+1]);
     76         while(l<r)if(tbk[mid=l+r+1>>1]>=nk)l=mid;else r=mid-1;
     77         return check(st[l+1]);
     78     }else{
     79         l=xtb[id].l,r=xtb[id].r-1;
     80         if(l>r||nk<=tbk[l])return check(st[l]);
     81         if(nk>=tbk[r])return check(st[r+1]);
     82         while(l<r)if(tbk[mid=l+r+1>>1]<=nk)l=mid;else r=mid-1;
     83         return check(st[l+1]);
     84     }
     85     return puts("GG"),1;
     86 }
     87  
     88 int main(){
     89     n=read();bool flag=0;d mxx=-1e9,mnx=1e9;int la=0;
     90     while(n--){
     91         if(!read()){
     92             flag=1;
     93             st[++TOP]=++np,scanf("%lf%lf",&p[np].x,&p[np].y),p[np].x+=la,p[np].y+=la,
     94             mxx=max(mxx,p[np].x),mnx=min(mnx,p[np].x),
     95             _num++,stb[_num].l=stb[_num].r=xtb[_num].l=xtb[_num].r=TOP,_sz[_num]=1,
     96             _st[++_top]=_num;
     97             while(_sz[_st[_top-1]]==_sz[_st[_top]])
     98                 mergetb(_st[_top-1],_st[_top]),_top--;
     99         }else{
    100             scanf("%lf%lf",&NX,&NY),NX+=la,NY+=la;
    101             if(!flag){puts("No");continue;}
    102             if(!NY){
    103                 if(!NX)puts((la++,"Yes"));
    104                 else if(NX>0)puts((mnx*2+eps<=NX)?"No":(la++,"Yes"));
    105                 else puts((mxx*2>=eps+NX)?"No":(la++,"Yes"));
    106                 continue;
    107             }
    108             for(i=1;i<=_top;i++)if(!_check(_st[i]))break;
    109             puts(i>_top?(la++,"Yes"):"No");
    110         }
    111     }
    112 //  for(i=1;i<=_top;i++){
    113 //      printf("sz:%d
    ",_sz[_st[i]]);
    114 //      printf("stb:  ");for(j=stb[_st[i]].l;j<=stb[_st[i]].r;j++)printf("  (%.2lf,%.2lf)",p[st[j]].x,p[st[j]].y);puts("");
    115 //      printf("xtb:  ");for(j=xtb[_st[i]].l;j<=xtb[_st[i]].r;j++)printf("  (%.2lf,%.2lf)",p[st[j]].x,p[st[j]].y);puts("");
    116 //  }
    117 }
    View Code
  • 相关阅读:
    像素画
    随机世界生成2
    随机世界的生成
    unity2018使用tileMap生成地图 类似泰拉瑞亚创建和销毁地图块
    游戏反编译工具dnSpy
    unity物理学材质Physic Material
    bzoj3261: 最大异或和
    bzoj3524: [Poi2014]Couriers
    hdu2457:DNA repair
    poj2778:DNA Sequence
  • 原文地址:https://www.cnblogs.com/czllgzmzl/p/6160046.html
Copyright © 2011-2022 走看看