跳到正文

个人记录

CSP-S2023模拟总结

Soul_direction约 4 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年2月2日
篇幅
约 4 分钟

版本

  1. v1当前

T1

直接枚举可能,方案数等于总数的是可能的密码。

C++
signed main(){
	n=read();
	for(int i=1;i<=n;i++){
		int a=read(),b=read(),c=read(),d=read(),e=read();
		for(int j=0;j<=9;j++){
			f[(a+j)%10][b][c][d][e]++;
			f[a][(b+j)%10][c][d][e]++;
			f[a][b][(c+j)%10][d][e]++;
			f[a][b][c][(d+j)%10][e]++;
			f[a][b][c][d][(e+j)%10]++;
			f[(a+j)%10][(b+j)%10][c][d][e]++;
			f[a][(b+j)%10][(c+j)%10][d][e]++;
			f[a][b][(c+j)%10][(d+j)%10][e]++;
			f[a][b][c][(d+j)%10][(e+j)%10]++;
		}
	}
	for(int i=0;i<=9;i++)
	    for(int j=0;j<=9;j++)
	        for(int k=0;k<=9;k++)
	            for(int u=0;u<=9;u++)
	                for(int v=0;v<=9;v++)
	                    if(f[i][j][k][u][v]==n)ans++;
	write(ans);
	return 0;
}

T2

枚举开头向后跳,复杂度 O(Σn)O(\Sigma n),能拿 77 个点。

C++
signed main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=getchar();
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=i;j<=n;j++){
			if(!cnt)b[++cnt]=a[j];
			else{
				if(a[j]==b[cnt])cnt--;
				else b[++cnt]=a[j];
				if(!cnt)ans++;
			}
		}
	}
	write(ans);
	return 0;
}

T3

结构体估计得指针满天飞,但发现前 33 个点没结构体,直接开骗。

C++
signed main(){
	n=read();
	while(n--){
		int op=read();
		if(op==2){
			int p;
			string t,s;
			cin>>t>>s;
			if(t=="byte")p=1;
			if(t=="short")p=2;
			if(t=="int")p=4;
			if(t=="long")p=8;
			a[++cnt].typ=t;
			a[cnt].name=s;
			if(adp%p!=0)adp+=p-adp%p;
			a[cnt].l=adp;
			a[cnt].r=adp+p-1;
			adp+=p;
			write(a[cnt].l);
		}
		if(op==3){
			string s;
			cin>>s;
			for(int i=1;i<=cnt;++i)
				if(a[i].name==s){
					write(a[i].l);
					break;
				}
		}
		if(op==4){
			int addr=read();
			bool f=1;
			for(int i=1;i<=cnt;++i){
				if(a[i].l<=addr&&a[i].r>=addr){
					cout<<a[i].name<<'\n';
					f=0;
				}
			}
			if(f)puts("ERR");
		}
	}
	return 0;
}

T4

强行暴力,然后炸了。

原文