QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74820#5098. 第一代图灵机Bronya0 497ms36840kbC++142.1kb2023-02-04 10:04:422023-02-04 10:04:45

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 10:04:45]
  • Judged
  • Verdict: 0
  • Time: 497ms
  • Memory: 36840kb
  • [2023-02-04 10:04:42]
  • Submitted

answer

#include<bits/stdc++.h>
#define lson rt<<1
#define rson rt<<1|1

using namespace std;
int n,m,q;
int a[200005],c[200005];
long long sum[200005];
struct Seg{
	int ma;
	long long ans;
}t[200005<<2];
long long Find(int l,int r,int lim,int rt){
	if(l==r)return sum[l]-sum[max(t[rt].ma,lim)-1];
	int mid=l+r>>1;
	if(t[lson].ma>=lim)return max(Find(l,mid,lim,lson),t[rt].ans);
	return max(Find(mid+1,r,lim,rson),sum[mid]-sum[lim-1]);
}
long long calc(int l,int r,int L,int R,int &lim,int rt){
	int mid=l+r>>1;
	long long ans=0;
	if(l>=L&&r<=R){
		ans=Find(l,r,lim,1);
		lim=max(lim,t[rt].ma);
		return ans;
	}
	if(mid>=L)ans=max(calc(l,mid,L,R,lim,lson),ans);
	if(mid<R)ans=max(calc(mid+1,r,L,R,lim,rson),ans);
	return ans;
}
void modify(int l,int r,int d,int s,int rt){
	if(d<l||d>r)return;
	if(l==r){
		t[rt].ma=s;
		t[rt].ans=sum[l]-sum[s-1];
		return;
	}
	int mid=l+r>>1;
	if(mid>=d)modify(l,mid,d,s,lson);
	else modify(mid+1,r,d,s,rson);
	t[rt].ma=max(t[lson].ma,t[rson].ma);
	t[rt].ans=Find(mid+1,r,t[lson].ma,rson);

}
int last[200005];
void build(int l,int r,int rt){
	if(l==r){
		t[rt].ma=last[l];
		t[rt].ans=sum[l]-sum[last[l]-1];
		return;
	}
	int mid=l+r>>1;
	build(l,mid,lson);
	build(mid+1,r,rson);
	t[rt].ma=max(t[lson].ma,t[rson].ma);
	t[rt].ans=Find(mid+1,r,t[lson].ma,rson);
}
set<int>st[200005];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=m;i++)st[i].insert(0),st[i].insert(n+1);
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		st[c[i]].insert(i);
		auto It=prev(st[c[i]].lower_bound(i));
		last[i]=(*It)+1;
	}
	build(1,n,1);
	for(int i=1;i<=q;i++){
		int opt,x,y;
		scanf("%d%d%d",&opt,&x,&y);
		if(opt==1)printf("%lld\n",calc(1,n,x,y,x,1));
		else {
			auto It=st[c[x]].lower_bound(x);
			int u=*prev(It),v=*next(It);
			modify(1,n,v,u+1,1);
			st[c[x]].erase(It);
			c[x]=y;
			st[c[x]].insert(x);
			auto it=st[c[x]].lower_bound(x);
			u=*prev(it),v=*next(it);
			modify(1,n,v,x+1,1);modify(1,n,x,u+1,1);
		}
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 16704kb

input:

5000 200 5000
2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...

output:

1614189
827701
118571
1156355
963263
549956
118571
536513
827701
827701
963263
827701
1614189
799926
118571
664223
278414
176735
132348
1156355
827701
1590163
1614189
118571
277150
1614189
118571
799926
536513
118571
309558
409387
1614189
1614189
827701
536513
1614189
799926
1614189
85598
1614189
11...

result:

wrong answer 1st lines differ - expected: '118571', found: '1614189'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 497ms
memory: 34728kb

input:

200000 10 200000
55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...

output:

2502433464
397669560
776867863
1556635758
2502433464
2502433464
2502433464
2502433464
776867863
2502433464
8686701
140756262
1251199327
2502433464
2502433464
2502433464
1863309895
272741841
2502433464
2502433464
1251199327
938063021
156187672
1091596202
856121448
470499563
2502433464
938063021
62006...

result:

wrong answer 1st lines differ - expected: '1232419', found: '2502433464'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 366ms
memory: 36840kb

input:

200000 20000 200000
30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...

output:

645988069
2503247284
191148736
341686080
123710202
1270177029
491324750
1270177029
2503247284
341686080
42801975
271671537
251917570
2503247284
2503247284
949228863
645988069
949228863
2503247284
645988069
2503247284
962467511
324310141
46702944
1270177029
341686080
2503247284
85327694
1270177029
12...

result:

wrong answer 1st lines differ - expected: '46702944', found: '645988069'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%