QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662652#7367. 群岛jianhe0 41ms15652kbC++141.1kb2024-10-21 08:35:202024-10-21 08:35:20

Judging History

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

  • [2024-10-21 08:35:20]
  • 评测
  • 测评结果:0
  • 用时:41ms
  • 内存:15652kb
  • [2024-10-21 08:35:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e6+10;
ll n,q,op,x,v,a[N],t[N<<2],lazy[N<<2];
void up(ll rt){
	if(!lazy[rt]) t[rt]=max(t[rt<<1],t[rt<<1|1]);
	else t[rt]=0;
}
void build(ll rt,ll l,ll r){
	t[rt]=r;
	if(l==r) return;
	ll mid=l+r>>1;
	build(rt<<1,l,mid),build(rt<<1|1,mid+1,r);
}
void update(ll rt,ll l,ll r,ll rl,ll rr,ll k){
	if(rl>r||rr<l) return;
	if(l==r){t[rt]=(!(lazy[rt]+=k))*l;return;}
	if(rl<=l&&r<=rr){lazy[rt]+=k;up(rt);return;	}
	ll mid=l+r>>1;
	update(rt<<1,l,mid,rl,rr,k),update(rt<<1|1,mid+1,r,rl,rr,k);
	up(rt);
}
ll query(ll rt,ll l,ll r,ll rl,ll rr){
	if(rl>r||rr<l) return 0;
	if(rl<=l&&r<=rr) return t[rt];
	ll mid=l+r>>1;
	return max(query(rt<<1,l,mid,rl,rr),query(rt<<1|1,mid+1,r,rl,rr));
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>q;build(1,1,n);
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<i) update(1,1,n,a[i]+1,i,1);
	}
	while(q--){
		cin>>op>>x;
		if(op==2) cout<<query(1,1,n,1,x)<<"\n";
		else{
			cin>>v;
			if(a[x]<x) update(1,1,n,a[x]+1,x,-1);
			a[x]=v;
			if(a[x]<x) update(1,1,n,a[x]+1,x,1);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 1ms
memory: 7768kb

input:

7 7
7 3 2 7 3 5 3
1 3 4
2 4
1 2 6
2 2
2 5
1 5 3
2 3

output:

3
2
3
3

result:

ok 4 lines

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 7788kb

input:

13 13
5 7 10 13 7 2 10 7 9 5 12 7 13
1 5 7
2 13
2 12
2 10
1 12 10
1 8 13
2 3
2 6
2 6
1 6 7
1 10 8
2 4
1 1 5

output:

13
2
2
3
2
2
4

result:

wrong answer 4th lines differ - expected: '2', found: '3'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 41ms
memory: 15652kb

input:

100000 100000
100000 1 1 2 4 1 5 4 5 10 6 11 9 9 11 11 15 17 14 16 19 19 19 23 20 21 26 25 26 29 28 27 29 30 32 33 32 36 36 35 39 40 41 41 43 45 44 43 44 117 46 51 48 50 50 52 55 53 54 42 59 61 61 63 94 64 65 64 64 66 68 69 70 69 87 72 72 77 78 75 76 78 78 79 80 84 84 83 84 142 87 87 90 92 80 91 93 ...

output:

7955
55775
14385
34175
2440
73165
98605
66275
48055
140
40220
65770
85350
2700
57785
89645
52320
44385
54200
62575
76740
82355
42660
93240
54200
11140
18075
89645
31305
44385
69885
25525
51320
77075
25525
85350
69240
40220
97675
16865
80920
98310
140
43240
63465
84765
39615
25525
61155
63465
60855
6...

result:

wrong answer 51st lines differ - expected: '60795', found: '60855'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%