为什么?(玄关)
查看原帖
为什么?(玄关)
1131450
CDW20110412楼主2024/3/21 17:50
#include<bits/stdc++.h>
using namespace std;
string s;
int T,l,r;
int main(){
	cin>>s;
	cin>>T;
	while(T--){
		cin>>l>>r;
		string t=s.substr(l-1,r-l+1);
		bool ok=false;
		for(int i=0;i<(int)t.size();i++){
			if(t[i]!='a'){
				ok=true;
				break;
			}
		}
		if(ok==false){
			cout<<"NULL\nHappy Chinese New Year!\n";
		}
		int pos=0;
		for(int i=(int)t.size()-1;i>=0;i--){
			if(t[i]!='a'){
				pos=i;
				break; 
			}
		}
		t[pos]--;
		for(int i=pos+1;i<(int)t.size();i++){
			t[i]='z';
		}
		if(s.find(t)!=s.npos){
			cout<<"Happy New Year!\n";
		}
		else cout<<"Happy Chinese New Year!\n";
	}
	return 0;
} 
2024/3/21 17:50
加载中...