QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114816 | #6608. Descent of Dragons | Eric_cai | Compile Error | / | / | C++14 | 1.8kb | 2023-06-23 17:19:59 | 2023-06-23 17:20:02 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-23 17:20:02]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-23 17:19:59]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
int n,q,cnt;
int ls[maxn*30],rs[maxn*30],rt[maxn],p[maxn*4],w[maxn*30],fa[maxn*30];
int build(int id,int l,int r)
{
int x=++cnt;
p[id]=x;
if(l==r) return x;
int mid=(l+r)>>1;
ls[x]=build(id<<1,l,mid);
rs[x]=build(id<<1|1,mid+1,r);
fa[ls[x]]=fa[rs[x]]=x;
return x;
}
int merge(int id1,int id2,int l,int r)
{
if(id1==0 || id2==0) return id1+id2;
if(l==r) return id1;
int mid=(l+r)>>1;
ls[id1]=merge(ls[id1],ls[id2],l,mid);
rs[id1]=merge(rs[id1],rs[id2],mid+1,r);
fa[ls[id1]]=fa[rs[id1]]=id1;
return id1;
}
int update(int id,int &id1,int &id2,int l,int r,int x,int y)
{
if(id1==0) return 0;
if(id2==0) id2=++cnt;
if(l>=x && r<=y)
{
id2=merge(id2,id1,l,r);
if(p[id]==id1) p[id]=id2;
id1=0;
return;
}
int mid=(l+r)>>1,ret=0;
if(x<=mid) ret+=update(id<<1,ls[id1],ls[id2],l,mid,x,y);
if(y>mid) ret+=update(id<<1|1,rs[id1],rs[id2],mid+1,r,x,y);
fa[ls[id1]]=fa[rs[id1]]=id1,fa[ls[id2]]=fa[rs[id2]]=id2;
if(l!=r && ls[id1]+rs[id1]==0) id1=0;
if(l!=r && ls[id2]+rs[id2]==0) id2=0;
if(ret>0) if(p[id]==id1) p[id]=id2;
return ret;
}
int query(int id,int l,int r,int x,int y)
{
if(l>=x && r<=y)
{
id=p[id];
while(fa[id]!=0) id=fa[id];
return w[id];
}
int mid=(l+r)>>1,ret=0;
if(x<=mid) ret=max(ret,query(id<<1,l,mid,x,y));
if(y>mid) ret=max(ret,query(id<<1|1,mid+1,r,x,y));
return ret;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int k,l,r,x;
cin>>n>>q;
rt[0]=build(1,1,n);
for(int i=1;i<=q;i++)
{
cin>>k>>l>>r;
if(k==1)
{
cin>>x;
if(x>q) continue;
w[rt[x]]=w[rt[x+1]]=0;
update(1,rt[x],rt[x+1],1,n,l,r);
w[rt[x]]=x,w[rt[x+1]]=x+1;
}
if(k==2) cout<<query(1,1,n,l,r)<<'\n';
}
return 0;
}
Details
answer.code: In function ‘int update(int, int&, int&, int, int, int, int)’: answer.code:36:17: error: return-statement with no value, in function returning ‘int’ [-fpermissive] 36 | return; | ^~~~~~