QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#67190#5098. 第一代图灵机pzr0 571ms43264kbC++141.5kb2022-12-10 10:30:352022-12-10 10:31:05

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.
  • [2022-12-10 10:31:05]
  • Judged
  • Verdict: 0
  • Time: 571ms
  • Memory: 43264kb
  • [2022-12-10 10:30:35]
  • Submitted

answer

#include<bits/stdc++.h>
#define ll long long
#define N 400000
using namespace std;
int n,m,q,c[N],x,y,tol;
ll a[N],last[N],f[N*4],g[N*4];
set<int>b[N];
ll solve(int k,int l,int r,ll pre){
	if(l==r)return a[l]-max(pre,g[k]);
	int mid=(l+r)>>1;
	if(g[k*2]>=pre)
	return max(f[k],solve(k*2,l,mid,pre));
	else return solve(k*2+1,mid+1,r,pre);
}
void join(int k,int l,int r,int x,int y){ 
	if(l==r){
		g[k]=a[y];f[k]=0;return;
	}int mid=(l+r)>>1;
	if(x<=mid)join(k*2,l,mid,x,y);
	else join(k*2+1,mid+1,r,x,y);
	g[k]=max(g[k*2],g[k*2+1]);f[k]=solve(k*2+1,mid+1,r,g[k*2]);
}
ll get(int k,int l,int r,int x,int y,ll z){
	if(l>=x&&r<=y)return solve(k,l,r,z);
	int mid=(l+r)>>1;ll sum=0;
	if(x<=mid)sum=max(sum,get(k*2,l,mid,x,y,z));
	if(y>mid)sum=max(sum,get(k*2+1,mid+1,r,x,y,max(z,g[k*2])));
	return sum;
}
int main(){
//	freopen("a2.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++)b[i].emplace(0);
	for(int i=1;i<=n;i++)
	{scanf("%lld",&a[i]);a[i]+=a[i-1];}
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		auto it=b[c[i]].emplace(i).first;
		join(1,1,n,i,*prev(it));
	}
	for(;q;q--){
		scanf("%d",&tol);
		if(tol==2){
			scanf("%d%d",&x,&y);
			auto it=b[c[x]].find(x);
			if(next(it)!=b[c[x]].end())
			join(1,1,n,*next(it),*prev(it));
			b[c[x]].erase(x);c[x]=y;
			it=b[c[x]].emplace(x).first;
			if(next(it)!=b[c[x]].end())
			join(1,1,n,*next(it),*it);
			join(1,1,n,*it,*prev(it));
		}else{
			scanf("%d%d",&x,&y);
			printf("%lld\n",get(1,1,n,x,y,a[x-1]));
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 23076kb

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:

116965
86120
69130
91878
91878
83553
64039
91394
91394
91394
91394
86120
91394
91394
73382
116965
83553
91878
48106
116965
91394
91878
91394
39374
86120
116965
88831
91394
91394
88831
82538
91394
116965
91394
91394
91394
91878
91394
91394
26617
91878
88831
91394
116965
91878
91394
88831
91394
60731
...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 571ms
memory: 42276kb

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:

1214212
1101806
1214212
1214212
1214212
1214212
1214212
1214212
1214212
1214212
1019832
1040942
1214212
1214212
1214212
1214212
1184783
1038866
1214212
1214212
1214212
1101806
1160928
1180499
1214212
1101806
1214212
1101806
1160928
1160928
963361
1214212
1214212
1160928
1160928
1214212
1101806
10302...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 475ms
memory: 43264kb

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:

35635318
36934855
31817682
31817682
29257985
36934855
31817682
35635318
36934855
31817682
27438528
32484460
35635318
36934855
36934855
36934855
31817682
36934855
36934855
33444716
36934855
36664481
35635318
30131111
36664481
31817682
36934855
23397886
35635318
36934855
36664481
31662866
36934855
369...

result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%