QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#189698 | #6608. Descent of Dragons | cqbzly | WA | 1ms | 3616kb | C++14 | 1.6kb | 2023-09-27 19:46:53 | 2023-09-27 19:46:54 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
const int N=5e5+5;
int n,Q,rt[N],tot;
struct node{
int ls,rs;
bool f;
}t[N<<5];
void build(int &p,int l,int r){
p=++tot;t[p].f=1;
if(l==r)return;
int mid=l+r>>1;
build(t[p].ls,l,mid);
build(t[p].rs,mid+1,r);
}
void pushup(int p){
t[p].f=t[t[p].ls].f|t[t[p].rs].f;
}
void update(int p,int &q,int l,int r,int ql,int qr){
if(ql<=l&&r<=qr){
q=p;
return;
}int mid=l+r>>1;q=++tot;
if(ql<=mid)update(t[p].ls,t[q].ls,l,mid,ql,qr);
if(mid<qr)update(t[p].rs,t[q].rs,mid+1,r,ql,qr);
pushup(q);
}
int query(int p,int l,int r,int ql,int qr){
if(!p)return 0;
if(ql<=l&&r<=qr)return t[p].f;
int mid=l+r>>1;
if(qr<=mid)return query(t[p].ls,l,mid,ql,qr);
if(mid<ql)return query(t[p].rs,mid+1,r,ql,qr);
return (query(t[p].ls,l,mid,ql,qr)|query(t[p].rs,mid+1,r,ql,qr));
}
int main(){
//freopen("data.in","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>Q;build(rt[0],1,n);
for(int i=1;i<=Q;i++){
int op,l,r,x;
cin>>op>>l>>r;
if(op==1){
cin>>x;
update(rt[x],rt[x+1],1,n,l,r);
}
else{
int L=0,R=i,res=0;
while(L<=R){
int mid=L+R>>1;
if(query(rt[mid],1,n,l,r))res=mid,L=mid+1;
else R=mid-1;
}cout<<res<<"\n";
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3452kb
input:
5 5 1 3 5 0 1 1 4 1 1 1 5 2 2 2 2 2 4 5
output:
0 3
result:
ok 2 number(s): "0 3"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3616kb
input:
1000 1000 2 234 913 1 693 735 47 1 702 959 94 2 273 286 1 814 896 47 1 560 566 15 1 46 699 97 2 494 527 1 721 879 68 1 87 437 26 1 163 938 15 1 816 912 58 2 284 670 2 713 763 1 49 542 13 1 669 874 41 2 795 855 1 601 962 93 1 413 747 50 1 528 710 73 2 255 435 1 329 871 86 1 24 236 48 1 22 48 41 1 29 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 2 2 2 0 2 2 2 2 2 2 0 0 2 0 0 0 3 3 3 0 0 0 1 1 1 3 2 2 2 2 3 1 3 2 2 3 3 2 2 1 0 2 3 3 3 3 0 3 3 2 2 0 3 2 3 2 1 0 2 2 0 2 2 2 0 0 2 0 0 2 0 0 0 2 0 2 2 2 2 0 2 2 0 0 2 0 0 2 0 2 0 0 3 4 4 0 4 0 4 0 4 4 4 ...
result:
wrong answer 38th numbers differ - expected: '2', found: '0'