QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#74829#5098. 第一代图灵机MEKHANE0 12ms19684kbC++171.4kb2023-02-04 11:06:382023-02-04 11:06:41

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 11:06:41]
  • Judged
  • Verdict: 0
  • Time: 12ms
  • Memory: 19684kb
  • [2023-02-04 11:06:38]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define mid (l+r)/2
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
using namespace std;
const int N=2e5+22;
int n,m,q,a[N],b[N],c[N],t[N*4],t1[N*4],nxt[N],opt,x,y,ans;
set<int> se[N];
int xw(int k,int l,int r,int z){
	if(z<t[k]) return 0;
	if(l==r) return a[z]-a[l];
	if(z<t[k*2+1]) return xw(k*2,l,mid,z);
	else return max(xw(k*2+1,mid+1,r,z),t1[k]);
}
int qry(int k,int l,int r,int L,int R,int &z){
	if(z<t[k]) return 0;
	if(L<=l&&r<=R) {int res=xw(k,l,r,z); z=min(z,t[k]-1); return res;} 
	int mx=0;
	if(L<=mid) mx=max(mx,qry(k*2,l,mid,L,R,z));
	if(mid<R) mx=max(mx,qry(k*2+1,mid+1,r,L,R,z));
	return mx;
}
void gx(int k,int l,int r,int wz,int z){
	if(l==r) {t[k]=z; return ;} 
	if(wz<=mid) gx(k*2,l,mid,wz,z);
	else gx(k*2+1,mid+1,r,wz,z);
	t[k]=min(t[k*2],t[k*2+1]),t1[k]=xw(k*2,l,mid,t[k*2+1]-1);
}
void gb(int x,int y){nxt[x]=y,gx(1,1,n,x,y);}
signed main(){
	ios::sync_with_stdio(false);
	cin>>n>>m>>q;
	rep(i,1,n) cin>>a[i],a[i]+=a[i-1];
	rep(i,1,m) se[i].insert(0),se[i].insert(n+1);
	rep(i,1,n) cin>>c[i],se[c[i]].insert(i);
	rep(i,1,n) gb(i,*se[c[i]].upper_bound(i));
	rep(i,1,q){
		cin>>opt>>x>>y;
		if(opt==1) ans=qry(1,1,n,x,y,y),cout<<max(ans,a[y]-a[x-1])<<endl;
		else{
			auto it=se[c[x]].find(x);
			gb(*prev(it),*next(it));
			se[c[x]].erase(x),c[x]=y;
			se[y].insert(x),it=se[y].find(x);
			gb(*prev(it),x),gb(x,*next(it));
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 19684kb

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:

6757417
4242455
946525
3879879
3839489
837917
760139
3752142
6555680
6600573
4366688
3958088
4041861
5637579
295578
2024870
818244
309231
234167
3321857
6748501
1480492
6541540
39374
1694270
6292064
434666
3503078
3254847
1155878
1181089
2370815
7696655
7118975
6028149
3789692
9800015
2867772
750726...

result:

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

Subtask #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

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:

14520150965
3010127807
3091862976
4121604780
10593259660
14836024319
14042420368
10454055487
2829378780
16087982963
156793393
691473482
13167831293
11618753352
15869529488
9622077227
4998463368
682530093
7604141390
13314621017
12595911600
5290378480
4767572878
3799097875
2601971399
3586649777
136895...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded

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:

6621570926
13369649242
931196267
2620448320
750228117
9534864228
3004960664
9839523563
13389184978
2836609387
124823369
546615127
3314855629
13401800941
12305670413
3918343856
4220403622
4195372239
17909467335
4642609744
12144115606
5386102380
3380303636
1694808168
11931212456
2557854406
14743095279...

result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%