QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619602#8179. 2D ParenthesesFiyulsCompile Error//C++143.0kb2024-10-07 14:45:372024-10-07 14:45:38

Judging History

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

  • [2024-10-07 14:45:38]
  • 评测
  • [2024-10-07 14:45:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define make(a,b) make_pair(a,b)
const int maxn=4e5+5;
struct node{
    int x,y,col,id;
    bool operator<(const node a)const{
        return (y!=a.y)?y<a.y:x<a.x;
    }
    bool operator>(const node a)const{
        return (y!=a.y)?y>a.y:x>a.x;
    }
    bool operator==(const node a)const{
        return x==a.x and y==a.y;
    }
}nd[maxn];
struct pand{
    int x,ly,ry,op;
}pa[maxn];
int n,m,Cnt,lc,lisa[maxn],Comp[maxn];
set<node> sn;
int Tre[maxn<<2];
int query(int u,int stdl,int stdr,int l,int r){if(l>r)return 0;
    if(stdl==l and stdr==r){
        return Tre[u];
    }
    int mid=(stdl+stdr)>>1,lson=(u<<1),rson=lson+1;
    if(r<=mid)return query(lson,stdl,mid,l,r);else if(l>=mid+1)return query(rson,mid+1,stdr,l,r);
    else{
        return query(lson,stdl,mid,l,mid)+query(rson,mid+1,stdr,mid+1,r);
    }
}
void modify(int u,int stdl,int stdr,int x,int d){
    if(stdl==stdr){
        Tre[u]+=d;
        return;
    }
    int mid=(stdl+stdr)>>1,lson=(u<<1),rson=lson+1;
    if(x<=mid){
        modify(lson,stdl,mid,x,d);
    }else{
        modify(rson,mid+1,stdr,x,d);
    }
    Tre[u]=Tre[lson]+Tre[rson];
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        Cnt++,scanf("%d%d",&nd[Cnt].x,&nd[Cnt].y),nd[Cnt].id=i,nd[Cnt].col=0,lisa[++lc]=nd[Cnt].y;
    }
    for(int i=1;i<=n;i++){
        Cnt++,scanf("%d%d",&nd[Cnt].x,&nd[Cnt].y),nd[Cnt].id=i,nd[Cnt].col=1,lisa[++lc]=nd[Cnt].y;
    }
    sort(nd+1,nd+1+Cnt,[](node a,node b){return (a.x==b.x)?((a.col==b.col)?a.y>b.y:a.col<b.col):a.x>b.x;});
    for(int i=1;i<=Cnt;i++){
        if(nd[i].col==1){
            sn.insert(nd[i]);
        }else{
            node find=nd[i];
            find.y++;
            auto p=sn.lower_bound(find);
            if(p==sn.end()){
                printf("No");return 0;
            }
            Comp[nd[i].id]=(*p).id;
            pa[++m]=pand{(*p).x,nd[i].y,(*p).y,+1 };
            pa[++m]=pand{nd[i].x,nd[i].y,(*p).y,-1};
            sn.erase(p);
        }
    }
    sort(pa+1,pa+1+m,[](pand a,pand b){return (a.x==b.x)?a.op<b.op:a.x>b.x;});
    sort(lisa+1,lisa+1+lc),lc=unique(lisa+1,lisa+1+lc)-(lisa+1);
    for(int i=1,j=1;i<=m;i++){
        pa[i].ly=lower_bound(lisa+1,lisa+1+lc,pa[i].ly)-lisa;
        pa[i].ry=lower_bound(lisa+1,lisa+1+lc,pa[i].ry)-lisa;
        while(j<=m and (pa[j].x>pa[i].x||pa[j].x==pa[i].x and pa[j].op==-1)){
            modify(1,1,lc,pa[j].ly,pa[j].op  *pa[j].id);
            modify(1,1,lc,pa[j].ry,pa[j].op  *pa[j].id),j++;
        }
        if(query(1,1,lc,pa[i].ly+1,pa[i].ry-1)){
            if(n>=100){
                cout<<"i:"<<i<<"j:"<<j<<"que:"<<query(1,1,lc,pa[i].ly+1,pa[i].ry-1);
            }
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    for(int i=1;i<=n;i++){
        printf("%d\n",Comp[i]);
    }
    return 0;
}
/*
2
0 0
0 1
2 3
3 3
*/

Details

answer.code: In function ‘int main()’:
answer.code:78:53: error: ‘struct pand’ has no member named ‘id’
   78 |             modify(1,1,lc,pa[j].ly,pa[j].op  *pa[j].id);
      |                                                     ^~
answer.code:79:53: error: ‘struct pand’ has no member named ‘id’
   79 |             modify(1,1,lc,pa[j].ry,pa[j].op  *pa[j].id),j++;
      |                                                     ^~
answer.code:48:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:50:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |         Cnt++,scanf("%d%d",&nd[Cnt].x,&nd[Cnt].y),nd[Cnt].id=i,nd[Cnt].col=0,lisa[++lc]=nd[Cnt].y;
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:53:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |         Cnt++,scanf("%d%d",&nd[Cnt].x,&nd[Cnt].y),nd[Cnt].id=i,nd[Cnt].col=1,lisa[++lc]=nd[Cnt].y;
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~