一个点MLE了……
  • 板块P1246 编码
  • 楼主STUDENT00
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/9/10 23:08
  • 上次更新2023/10/27 12:04:07
查看原帖
一个点MLE了……
658786
STUDENT00楼主2022/9/10 23:08

代码如下:

#include<bits/stdc++.h>
using namespace std;
string str;
int k=-1;
queue<string> qt;
int main(){
	cin>>str;
	qt.push("");
	while(!qt.empty()){
		k++;
		string now=qt.front();
		if(now==str) break;
		int c;
		if(now.length()) c=now[now.length()-1]+1-'a';
		else c=0;
		for(int i=c;i<26;i++){
			string p=now;
			p+=char(i+'a');
			qt.push(p);
		}
		qt.pop();
	}
	printf("%d",k);
	return 0;
}
2022/9/10 23:08
加载中...