QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#121676#5098. 第一代图灵机275307894a0 3ms20408kbC++142.0kb2023-07-08 17:24:192023-07-08 17:24:21

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-07-08 17:24:21]
  • Judged
  • Verdict: 0
  • Time: 3ms
  • Memory: 20408kb
  • [2023-07-08 17:24:19]
  • Submitted

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pli=pair<ll,int>;using LL=__int128;
const int N=2e5+5,M=N*4+5,K=2e4+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,m,q,c[N];ll Sum[N];
set<int> f[N];
namespace Tree{
	#define ls v<<1
	#define rs v<<1|1
	int Mx[M];ll f[M],g[M];
	ll Find(int x,int l,int r,int v){
		if(l==r) return Sum[l]-Sum[max(x,Mx[v])];int m=l+r>>1;
		return x<=Mx[ls]?max(Find(x,l,m,ls),g[v]):max(Sum[m]-Sum[x],Find(x,m+1,r,rs));
	}
	void Up(int v,int m,int r){
		Mx[v]=max(Mx[ls],Mx[rs]);
		f[v]=max(f[ls],g[v]=Find(Mx[ls],m+1,r,rs));
	}
	void Ins(int x,int y,int l=1,int r=n,int v=1){
		if(l==r) {Mx[v]=y;f[v]=Sum[v]-Sum[y];return;}
		int m=l+r>>1;x<=m?Ins(x,y,l,m,ls):Ins(x,y,m+1,r,rs);Up(v,m,r);
	}
	ll qry(int x,int y,int &z,int l=1,int r=n,int v=1){
		if(x<=l&&r<=y) {ll p=Find(z,l,r,v);z=max(z,Mx[v]);return p;}
		int m=l+r>>1;return max(x<=m?qry(x,y,z,l,m,ls):0,y>m?qry(x,y,z,m+1,r,rs):0);
	}
	#undef ls
	#undef rs
}
int main(){
	int i,j;scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;i++) scanf("%lld",&Sum[i]),Sum[i]+=Sum[i-1];
	for(i=1;i<=m;i++) f[i].insert(0);
	for(i=1;i<=n;i++) scanf("%d",&c[i]),Tree::Ins(i,*f[c[i]].rbegin()),f[c[i]].insert(i);
	while(q--){
		int op,x,y;scanf("%d%d%d",&op,&x,&y);
		if(op==1) x--,printf("%lld\n",Tree::qry(x+1,y,x));
		else {
			f[c[x]].erase(x);
			auto p=f[c[x]].LB(x);
			if(p!=f[c[x]].end()){
				auto q=p;q--;Tree::Ins(*p,*q);
			}
			c[x]=y;
			p=f[c[x]].LB(x);
			auto q=p;q--;Tree::Ins(x,*q);
			if(p!=f[c[x]].end()) Tree::Ins(*p,x);
			f[c[x]].insert(x);
		}
	}
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 20408kb

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:

428064
136303
43608
381002
667560
628229
126242
398077
226461
210951
170534
136303
258987
228052
32012
163511
127706
304232
33448
144071
1253911
587282
2491
39374
648685
467419
437547
102096
244579
60848
501619
36111
42726
85854
459079
52918
701570
466602
19512
34330
1770070
963740
170534
1802092
14...

result:

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

Subtask #2:

score: 0
Runtime Error

Test #3:

score: 0
Runtime Error

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:


result:


Subtask #3:

score: 0
Runtime Error

Test #5:

score: 0
Runtime Error

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:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%