QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120310#6608. Descent of Dragonsc20230201WA 1ms3560kbC++141.5kb2023-07-06 16:38:202023-07-06 16:38:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 16:38:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2023-07-06 16:38:20]
  • 提交

answer

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

const int maxn=5e5+5, maxt=1e7+5;

int tot;
int a[maxn], rt[maxn];

struct node {
	int ls=0;
	int rs=0;
	int v=0;
}t[maxt];

void pushup(int rt) {
	t[rt].v=(t[t[rt].ls].v|t[t[rt].rs].v);
	return ;
}

void build(int& rt,int l,int r) {
	if(!rt) rt=++tot;
	t[rt].v=1;
	if(l==r) return ;
	int mid=l+r>>1;
	build(t[rt].ls,l,mid);
	build(t[rt].rs,mid+1,r);
	return ;
}

void updata(int rt1,int& rt2,int l,int r,int L,int R) {
	if(L<=l&&r<=R) {
		rt2=rt1;
		return ;
	}
	if(!rt2) rt2=++tot;
	int mid=l+r>>1;
	if(L<=mid) updata(t[rt1].ls,t[rt2].ls,l,mid,L,R);
	if(mid<R) updata(t[rt1].rs,t[rt2].rs,mid+1,r,L,R);
	pushup(rt2);
	return ;
}

int query(int rt,int l,int r,int L,int R) {
	if(!rt) return 0;
	if(L<=l&&r<=R) return t[rt].v;
	int mid=l+r>>1, res=0;
	if(L<=mid) res|=query(t[rt].ls,l,mid,L,R);
	if(mid<R) res|=query(t[rt].rs,mid+1,r,L,R);
	return res;
}

int main() {
//	freopen("debt.in","r",stdin);
//	freopen("debt.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n,q; cin>>n>>q;
	build(rt[0],1,n);
	for(int i=1;i<=q;i++) {
		int op; cin>>op;
		if(op==1) {
			int l,r,x; cin>>l>>r>>x;
			updata(rt[x],rt[x+1],1,n,l,r);
		}else {
			int l,r,pos=0; cin>>l>>r;
			int ll=0, rr=i-1, ans=0;
			while(ll<=rr) {
				int mid=(ll+rr)>>1;
				if(query(rt[mid],1,n,l,r)) ll=mid+1, ans=mid;
				else rr=mid-1;
			}
			cout<<ans<<'\n';
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

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: 3560kb

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
2
2
0
2
0
0
0
0
2
0
2
2
2
2
2
2
2
2
2
2
0
0
2
0
0
0
3
3
3
0
0
0
1
1
1
3
3
2
2
3
3
1
3
2
3
3
3
3
3
1
3
2
3
3
3
3
3
3
3
3
2
3
3
3
3
2
3
3
3
2
1
3
3
3
1
1
3
2
3
3
1
1
3
3
2
3
3
3
3
3
3
3
2
2
3
3
2
3
1
3
3
2
3
4
4
4
4
2
4
2
4
4
4
...

result:

wrong answer 74th numbers differ - expected: '2', found: '3'