【BZOJ】【P3678】【wangxz与OJ】【题解】【rope】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3678

LZT大爷的题,怒Dwangxz……

rope水过,出题人用的块链,还有就是此题卡内存,用short才过……

Code:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
rope<short>T;
short a[100000];
int n,m;
int getint(){
	int res=0,f=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))res=(res<<3)+(res<<1)+ch-'0',ch=getchar();
	return res*f;
}
void deb(){
	for(int i=0;i<T.size();i++)
	printf("%d%c",T[i]," \n"[i==T.size()-1]);
}
int main(){
	n=getint(),m=getint();
	for(int i=0;i<n;i++)a[i]=getint();
	T=rope<short>(a,a+n);
	while(m--){
		int op=getint();
		if(op==0){
			int p=getint(),l=getint(),r=getint();
			int j=0;
			for(int i=l;i<=r;i++)a[j++]=i;
			T=T.substr(0,p)+rope<short>(a,a+r-l+1)+T.substr(p,T.size()-p);
		}else
		if(op==1){
			int l=getint(),r=getint();
			T=T.substr(0,l-1)+T.substr(r,T.size()-r);
		}else
		if(op==2){
			int p=getint();
			printf("%d\n",T[p-1]);
		}
	}
	return 0;
}


你可能感兴趣的:(bzoj,省选)