提交记录 16512


用户 题目 状态 得分 用时 内存 语言 代码长度
gyh20 noi17b. 【NOI2017】蚯蚓排队 Accepted 100 979.759 ms 82824 KB C++ 2.02 KB
提交时间 评测时间
2021-09-22 21:05:35 2021-09-22 21:05:45
#include<cstdio>
#define re register
#define ull unsigned long long
using namespace std;
const int Mxdt=1000000;	//单次大小 
inline char gc(){
	static char buf[Mxdt],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,Mxdt,stdin),p1==p2)?EOF:*p1++;
}
inline char pc(char ch,bool bj){
	static char buf[Mxdt],*p1=buf,*p2=buf+Mxdt;
	return (bj||(*p1++=ch)&&p1==p2)&&fwrite(p1=buf,1,p1-buf,stdout),0;
}
void print(int x)
{
	if(x>9)print(x/10);
	pc(x%10^48,false);
}
inline void printnum(int x,char ch)
{
	print(x),pc(ch,false);
}
inline int read(){
	re int t=0;re char v=gc();
	while(v<'0')v=gc();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=gc();
	return t;
}
int nxt[20000002],cnt,val[20000002];
ull to[20000002],pw[52],B=131;
struct hashtable{
	int head[65536];
	inline void ins(re ull x,re int y){
		re int tmp=x&65535;
		for(re int i=head[tmp];i;i=nxt[i])if(to[i]==x){val[i]+=y;return;}
		to[++cnt]=x,nxt[cnt]=head[tmp],head[tmp]=cnt,val[cnt]=y;
	}
	inline int ask(re ull x){
		re int tmp=x&65535;
		for(re int i=head[tmp];i;i=nxt[i])if(to[i]==x)return val[i];
		return 0;
	}
}H[52];
int n,L[500002],R[500002],m,l,a[500002],k;
char s[10000002];
const int M=998244353;
int main(){
	n=read(),m=read();
	for(re int i=pw[0]=1;i<=n;++i)pw[i]=pw[i-1]*B;
	for(re int i=1;i<=n;++i)a[i]=read(),H[1].ins(a[i],1);
	while(m--){
		re int o=read();
		if(o==3){
			l=0;
			while(s[l]^' ')s[++l]=gc();
			k=read(),--l;
			re ull hsh=0;
			for(re int i=1;i<=k;++i)hsh=hsh*B+s[i]-'0';
			re int ans=H[k].ask(hsh);
			for(re int i=k+1;i<=l;++i)hsh=hsh*B+s[i]-'0',hsh-=pw[k]*(s[i-k]-'0'),ans=1ll*ans*H[k].ask(hsh)%M;
			printnum(ans,'\n');
		}
		else if(o==2){
			re int x=R[read()];
			for(re int s=L[x],t=1;s&&t<=50;++t,s=L[s]){
				re ull hsh=0;
				for(re int y=s,c=1;c<=50&&y;++c,y=R[y]){hsh=hsh*B+a[y];if(c>t)H[c].ins(hsh,-1);}
			}
			R[L[x]]=0,L[x]=0;
		}
		else{
			re int x=read(),y=read();
			R[x]=y,L[y]=x;
			for(re int s=x,t=1;s&&t<=50;++t,s=L[s]){
				re ull hsh=0;
				for(re int y=s,c=1;c<=50&&y;++c,y=R[y]){hsh=hsh*B+a[y];if(c>t)H[c].ins(hsh,1);}
			}
		}
	}
	pc('o',1);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #123.58 us68 KBAcceptedScore: 4

Testcase #244.12 us296 KBAcceptedScore: 4

Testcase #37.767 ms4 MB + 256 KBAcceptedScore: 4

Testcase #4952.72 us7 MB + 188 KBAcceptedScore: 4

Testcase #55.667 ms6 MB + 780 KBAcceptedScore: 4

Testcase #684.276 ms31 MB + 796 KBAcceptedScore: 4

Testcase #718.585 ms2 MB + 4 KBAcceptedScore: 4

Testcase #853.417 ms28 MB + 788 KBAcceptedScore: 4

Testcase #990.357 ms32 MB + 692 KBAcceptedScore: 4

Testcase #10106.84 ms30 MB + 112 KBAcceptedScore: 4

Testcase #11207.264 ms37 MB + 852 KBAcceptedScore: 4

Testcase #12105.415 ms34 MB + 964 KBAcceptedScore: 4

Testcase #1344.229 ms3 MB + 124 KBAcceptedScore: 4

Testcase #14132.561 ms42 MB + 784 KBAcceptedScore: 4

Testcase #15167.266 ms45 MB + 264 KBAcceptedScore: 4

Testcase #16286.484 ms45 MB + 416 KBAcceptedScore: 4

Testcase #17433.889 ms52 MB + 344 KBAcceptedScore: 4

Testcase #18429.969 ms74 MB + 840 KBAcceptedScore: 4

Testcase #19541.844 ms80 MB + 904 KBAcceptedScore: 4

Testcase #20103.348 ms29 MB + 280 KBAcceptedScore: 4

Testcase #2196.613 ms5 MB + 48 KBAcceptedScore: 4

Testcase #22348.437 ms68 MB + 296 KBAcceptedScore: 4

Testcase #23381 ms69 MB + 364 KBAcceptedScore: 4

Testcase #24787.833 ms73 MB + 528 KBAcceptedScore: 4

Testcase #25979.759 ms80 MB + 4 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:38:50 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠