QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#349718#4236. Triangular LogsLaStataleBlueCompile Error//C++234.8kb2024-03-10 04:39:302024-03-10 04:39:30

Judging History

你现在查看的是最新测评结果

  • [2024-03-10 04:39:30]
  • 评测
  • [2024-03-10 04:39:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int MAXN = 100'005, NUM = 50, inf = 1e9+7;
int contx=0,conty=0;
array<int,NUM> inf2;

array<int,NUM> merge(array<int,NUM> a,array<int,NUM> b){
    array<int,NUM> res;
    int inda=0,indb=0;
    for(int i=0;i<NUM;i++){
        if(inda==NUM)res[i]=b[indb++];
        else if(indb==NUM)res[i]=a[inda++];
        else if(a[inda]<b[indb]){
            res[i]=a[inda++];
        }else{
            res[i]=b[indb++];
        }
    }
    return res;
}

#define _mid (_l+_r)/2
struct SegmentTree2{
    array<int,NUM> maxi;
    SegmentTree2 *left,*right;
    
    static SegmentTree2* newSeg();
    
    void checkleft(){
        if(left==nullptr)left=newSeg();
    }
    
    void checkright(){
        if(right==nullptr)right=newSeg();
    }
    
    void update(int pos,int val,int _l,int _r){
        if(pos<_l || pos>_r)return;
        
        for(int i=0;i<NUM;i++){
            if(maxi[i]>val){
                for(int j=NUM-1;j>i;j--){
                    maxi[j]=maxi[j-1];
                }
                maxi[i]=val;
                break;
            }
        }
        
        if(_l!=_r){
            if(pos<=_mid){
                checkleft();
                left->update(pos,val,_l,_mid);
            }
            
            if(pos>_mid){
                checkright();
                right->update(pos,val,_mid+1,_r);
            }
        }
    }
    
    array<int,NUM> query(int l,int r,int _l,int _r){
        if(r<_l || l>_r || l>r)return inf2;
        if(_l>=l && _r<=r)return maxi;
        
        array<int,NUM> res = inf2;
        
        if(left!=nullptr){
            res = merge(res,left->query(l,r,_l,_mid));
        }
        if(right!=nullptr){
            res = merge(res,right->query(l,r,_mid+1,_r));
        }
        return res;
    }
};
SegmentTree2 vett2[11'000'000];
int cc2=0;

SegmentTree2* SegmentTree2::newSeg(){
    if(cc2==11'000'000)exit(0);
    int ind = cc2++;
    vett2[ind].maxi=inf2;
    return &vett2[ind];
}

struct SegmentTree{
    map<int,pair<int,vector<int>>> ind;
    SegmentTree2 *ds;
    SegmentTree *left,*right;
    
    static SegmentTree* newSeg(int _l,int _r);
    
    void update(int x,int y,int val,int _l,int _r){
        if(_r<x || _l>x)return;
        

        ind[y].first=0;
        ind[y].second.push_back(val);
        
        if(_l!=_r){
            left->update(x,y,val,_l,_mid);
            right->update(x,y,val,_mid+1,_r);
        }
    }
    
    void crea(int _l,int _r){
        
        ind[inf]={0,{}};
        int cont=0;
        for(auto &[i,j] : ind){
            j.first=cont;
            for(auto x : j.second){
                ds->update(cont,x,0,ind.size());
            }
            cont++;
        }
        
        if(_l!=_r){
            left->crea(_l,_mid);
            right->crea(_mid+1,_r);
        }
    }
    
    array<int,NUM> query(int x1,int x2,int y1,int y2,int _l,int _r){
        if(x1>_r || x2<_l || x1>x2)return inf2;
        if(_l>=x1 && _r<=x2){
            y1 = ind.lower_bound(y1)->second.first;
            y2 = ind.upper_bound(y2)->second.first;
            
            return ds->query(y1,y2-1,0,ind.size());
        }
        
        return merge(left->query(x1,x2,y1,y2,_l,_mid),right->query(x1,x2,y1,y2,_mid+1,_r));
    }
};


SegmentTree vett[MAXN*2+10];
int cc=0;

SegmentTree* SegmentTree::newSeg(int _l,int _r){
    if(cc==MAXN*2+10)while(true);//exit(0);
    int ind = cc++;
    
    vett[ind].ds = SegmentTree2::newSeg();
    if(_l!=_r){
        vett[ind].left=newSeg(_l,_mid);
        vett[ind].right=newSeg(_mid+1,_r);
    }
    
    return &vett[ind];
}

void solve([[maybe_unused]] int t){
    int n,q;
    cin>>n>>q;
    
    vector<int> x(n),y(n),h(n);
    map<int,int> tmpx;
    
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
        tmpx[x[i]]=0;
    }
    tmpx[inf]=0;
    
    
    for(auto &[i,j] : tmpx){
        j=contx++;
    }
    
    SegmentTree *ds = SegmentTree::newSeg(0,contx);
    
    for(int i=0;i<n;i++){
        ds->update(tmpx[x[i]],y[i],h[i],0,contx);
    }
    ds->crea(0,contx);
    
    for(int i=0;i<q;i++){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        
        x1 = tmpx.lower_bound(x1)->second;
        x2 = tmpx.upper_bound(x2)->second;
        
        array<int,NUM> ans = ds->query(x1,x2-1,y1,y2,0,contx);
        
        bool ok = false;
        for(int j=2;j<NUM;j++){
            if(ans[j]==inf)continue;
            if(ans[j]<ans[j-1]+ans[j-2])ok=true;
        }
        
        cout<<ok<<"\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    for(int i=0;i<NUM;i++)inf2[i]=inf;
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

详细

/tmp/ccadXopi.o: in function `SegmentTree2::newSeg()':
answer.code:(.text+0x89e): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8a6): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8b5): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8bd): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8cc): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8d4): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8e6): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8ee): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x8fa): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x902): relocation truncated to fit: R_X86_64_PC32 against symbol `inf2' defined in .bss section in /tmp/ccadXopi.o
answer.code:(.text+0x90f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status