一种很新的做法
查看原帖
一种很新的做法
1212465
SilVeR__WolF楼主2024/4/20 15:45

主要利用了a ASCII值上一个是 ‘`’

#include<bits/stdc++.h>
using namespace std;
string p,sub,upsub;
int n,l,r,sz;

int main(){
//	freopen("o.in","r",stdin);
	cin>>p>>n;
	for(int i=0;i<n;i++)
	{
		cin>>l>>r;
		sub=p.substr(l-1,r-l+1) , sz=r-l+1;
		upsub="a"+sub;
		upsub[sz]-=1;
		for(int j=sz;j>=1;j--)
		{
			if(upsub[j]=='`')
				upsub[j-1]--,upsub[j]='z';
		}
		if(upsub[0]=='`')
			cout<<"NULL\nHappy Chinese New Year!\n";
		else
		{
			string fi=upsub.substr(1,sz);
			cout<<fi<<"\n";
			int s=(int)p.find(fi);
			if(s==-1)
				cout<<"Happy Chinese New Year!\n";
			else
				cout<<"Happy New Year!\n";
		}
	}
	return 0;
}
```cpp
2024/4/20 15:45
加载中...