QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#446340#4214. Deja VuPure_FuriesRE 0ms0kbC++142.9kb2024-06-17 08:34:112024-06-29 06:56:43

Judging History

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

  • [2024-06-29 06:56:43]
  • 管理员手动重测本题所有提交记录
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-06-28 21:31:34]
  • hack成功,自动添加数据
  • (/hack/708)
  • [2024-06-17 08:34:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-06-17 08:34:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int w[1048576][32],I,G[2];
int msk,pm[32][2];
void pu(int k){
	memset(w[k],0,64);
	for(int i=2;i<16;i+=2){
		pm[i][0]=pm[(i>>2)<<1][0]<<1;
		pm[i][1]=pm[(i>>2)<<1][1]<<1;
		if((i&2)||w[k<<1][i>>1]!=w[k][pm[(i>>2)<<1][0]])
			pm[i][0]^=2;
		if((i&2)||w[k<<1|1][i>>1]!=w[k][pm[(i>>2)<<1][1]])
			pm[i][1]^=2;
		if(w[k][pm[i][0]]<w[k<<1][i])
			w[k][pm[i][0]|1]=max(w[k][pm[i][0]],w[k<<1][i|1]),
			w[k][pm[i][0]]=w[k<<1][i];
		else
			w[k][pm[i][0]|1]=max(w[k][pm[i][0]|1],w[k<<1][i|(w[k][pm[i][0]]==w[k<<1][i])]);
		if(w[k][pm[i][1]]<w[k<<1|1][i])
			w[k][pm[i][1]|1]=max(w[k][pm[i][1]],w[k<<1|1][i|1]),
			w[k][pm[i][1]]=w[k<<1|1][i];
		else
			w[k][pm[i][1]|1]=max(w[k][pm[i][1]|1],w[k<<1|1][i|(w[k][pm[i][1]]==w[k<<1|1][i])]);
	}
}
int mp[32];
void PD(int k,int *F){
	for(int K=(k<<1);K<(k+1<<1);K++){
		F[K&1]=0;
		for(int i=2;i<32;i+=2){
			mp[i]=mp[(i>>2)<<1]<<1;
			if((i&2)||w[K][i>>1]!=w[k][mp[(i>>2)<<1]])
				mp[i]^=2;
			w[K][i]=min(w[K][i],w[k][mp[i]]);
			if(msk&1<<mp[i])
				F[K&1]|=1<<i;
		}
	}
	for(int i=16;i<32;i+=2)
		w[k][i]=1e9;
}
void op(int _l,int _r,int l,int r,int k,int x,int v){
	if(l>_r||r<_l||l>r)return;
	int F[2],A,B=0;
	if(l<=_l&&_r<=r){
		while(v){
			A=0;
			for(int i=2;i<16;i++)
				if(1<<i&v)
				if(w[k][i]<x){
					if(i<8)
						A|=(1<<(i<<1)),
						A|=(4<<(i<<1));
					else
						w[k][i<<1]=min(w[k][i<<1],I),
						w[k][i+1<<1]=min(w[k][i+1<<1],I);
				}else if(w[k][i+1]<x){
					w[k][i]=min(w[k][i],x);
					if(i<8)
						A|=(4<<(i<<1));
					else
						w[k][i+1<<1]=min(w[k][i+1<<1],I);
				}else B|=1<<i;
			v=A;
		}
	}else B=v;
	if(!B)return;
	msk=B;
	PD(k,F);msk=0;
	op(_l,_l+_r>>1,l,r,k<<1,x,F[0]);
	op(_l+_r+1>>1,_r,l,r,k<<1|1,x,F[1]);
	pu(k);
}
void rmk(int l,int r,int p,int k){
	if(l==r){
		for(int i=2;i<32;i+=2)
			w[k][i]=1e9;
		return;
	}
	PD(k,G);
	if(p<=(l+r>>1)) 
		rmk(l,l+r>>1,p,k<<1);
	else
		rmk(l+r+1>>1,r,p,k<<1|1);
	pu(k); 
}
int n,T,m,v;
vector<pair<int,int> >opt[500003];
vector<int>qr[500003];
int main(){
	freopen("ds.in","r",stdin);
	freopen("ds.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>T;
	for(int i=0;i<1048576;i++)
		for(int j=2;j<32;j+=2)
			w[i][j]=1e9;
	for(int i=0;i<n;i++){
		cin>>v;
		opt[i].push_back({0,v});
	}
	while(T--){
		int tp,i;
		cin>>tp>>i;i--;
		if(tp==1){
			cin>>v;
			opt[i].push_back({m,v});
		}else
			qr[i].push_back(m++);
	}
	for(I=0;I<n;I++){
		for(auto j:qr[I])
			rmk(0,524287,j,1);
		opt[I].push_back({m,0});
		for(int j=0;j+1<opt[I].size();++j)
			if(opt[I][j].first!=opt[I][j+1].first)
				op(0,524287,opt[I][j].first,opt[I][j+1].first-1,1,opt[I][j].second,4); 
	}
	for(int i=1;i<524288;i++)PD(i,G);
	for(int i=0;i<m;i++)
		if(w[i+524288][16]<n)
			cout<<w[i+524288][16]+1<<'\n';
		else
			cout<<"-1\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

11 10
1 2 3 4 5 10 9 8 7 6 8
2 1
1 3 2
2 1
1 1 2
2 1
2 5
2 6
1 9 6
1 10 7
2 5

output:


result: